15,190 Topics
![]() | |
![]() | The user enters their first, middle and last names and the program prints their full name. |
![]() | this is code that thanks to vegaseat helped me convert my programs into python30 |
This is a simple program and all it does is fiddle with the registry and set the value of the desktop background to be the bmp file that you supply in the function. There are other things you can do with the windows registry, this is just one of the … | |
A brute force method. Finds the FIRST and SHORTEST periodicity in the input list. | |
This snippet defines a cachedProperty decorator. A cached property differs from a property in that it's value is only computed the first time that the property is accessed and then stored in the object's dict for later use. If the object's attribute is explicitely deleted, it will be computed again … | |
This snippet defines a function [icode]patfilter(pattern, rule, sequence)[/icode] which implements filtering a sequence of strings according to various criteria. The output is either a subsequence of strings, or a sequence of match objects. | |
Many threads in daniweb's python forum deal with menu based programs which run in a terminal. This snippet defines a handy class, MenuCrawler, to help writing such programs. Subclassing from this base classes and adding methods corresponding to a given set of menus allows one to build the menu-based application. … | |
This snippet defines a class which can group a collection of strings according to a given set of prefixes. Each string goes in the group of the longest prefix it contains. | |
This snippet allows your code to use the Mendeleiev's periodic table of elements. It defines a single function [icode]mendeleiev_table()[/icode] which returns the table as a python list of lists. | |
If you're not used to work with the standard module logging, this snippet will allow you to incorporate a logger in your application without effort. It gives you a starting point before you try to use more sophisticated features of the logging module. | |
Here is an example how to write a program to convert between units of distance, area, volume, weight, pressure, and energy. The wxPython GUI toolkit's wx.NoteBook() widget is used to make good use of the limited frame/window space available. | |
This is a command line utility which lists the names of all functions defined in a python source file with a [icode]def <name>[/icode] statement | |
A variation of the previous bouncing ball code. This time the upper left corner of the image rectangle simply follows the position of each mouse click. Use an image you have, in my case I used a small red ball in a black background. A simple code to experiment with. | |
Hey guys. I originally wrote this program as a University assignment. It's basically a simulated game of 'tanks' roaming around a grid blowing eachother up. It isn't intended to be the most exciting game in the universe, infact when you look at the programs' output there will just be a … | |
Returns the power set of the elements of a given list (even if some of those elements are also lists). | |
For more information on threading read this [B]excellent[/B] 4 page tutorial: [URL="http://www.devshed.com/c/a/Python/Basic-Threading-in-Python/"]http://www.devshed.com/c/a/Python/Basic-Threading-in-Python/[/URL] | |
Text to speech can be implemented in its simplest form using Microsoft's Component Object Model (COM) connecting to the Speech API (SAPI). The attached Python code shows you how to do this. | |
This short Python snippet shows you how to read mouse wheel events with the Tkinter GUI toolkit. Windows and Linux have different bindings and read different events, but can be included in the same program code for use with either operating system. | |
This well commented Python snippet uses wxPython's plotting widget to graph the projectile motion of two different firing angles on the same plotting canvas. | |
Hi all, Have you ever heard of "Petals Around the Rose?" It's a logic puzzle. The way it works is, I roll five dice, then tell you what the "score" is for this round. I can repeat this for you as many times as you want. It's your job to … | |
[URL="http://www.bitstorm.org/gameoflife/"]Life[/URL] is a "game" or cellular automaton - an evolving computational state system - developed by a Cambridge mathematician named John Conway. The idea is simple: start with a board of dimensions (x,y). Populate the board with an initial pattern of occupied and empty cells. In every turn, the rules … | |
Sometimes you want to accomplish something with a minimum ammount of code. Here is an example of using modern Python concepts of lambda, list comprehension and all() to create an anonymous function that returns a prime list from 2 to n. | |
A little program to convert angles to and from Decimal degrees, Degrees decimal minutes and Degrees minutes decimal seconds. | |
Written using Boa Constructor, with code added to do the conversion from C to F or F to C. The code has been altered to give a single file so don't open it in Boa Constructor. | |
A simple example of applying a font to a text displayed with wxPython's wx.StaticText widget. | |
Just bouncing a red ball within the frame of a window, the twist here is that the image is stored within the code as a base64 encoded string of the gif image. This way you only have to distribute one file. The Python code is heavily commented, so you can … | |
The Python module datetime allows you to calculate the days between two given dates with relative ease. I am using the US date format month/day/year, but you can change that by giving attention to the order of the extracted tuple. | |
Using count() from Python's itertools module and the Tkinter GUI toolkit's after() function, you can create a simple counter that counts up the seconds until the Stop button is pressed. | |
This code takes a string a cyphers it by shifting it's position in the alphabet. I've gotten it so it can pretty much take paragraphs. It's quite neat to play with. For example the above when shifted to 5, would be: Ymnx htij yfpjx f xywnsl f hDumjwx ny gD … | |
This one works pretty fast, even for large numbers. Like it says, aproxomite end number, and that is because it will generally go one fibonacci number above what you specify. |
The End.