32 Archived Topics
Remove Filter Most commonly a dictionary of key:value pairs is searched by the unique key. Sometimes it becomes necessary to search for the key, or keys given a value. Special consideration has to be given to this case, because the value does not have to be unique and may return several keys … | |
More or less a templet database that allows you to load, save, add, list, search, edit and delete data items. I used movies as an example, but you can easily change that to make a database of many other things. | |
Does anybody have experience with Python on the iPad? Is it easy to get and use Python? | |
Just a simple console blackjack game. The bread and butter code was written with lots of comments, so you can improve on it. Really, the most important part is figuring out when an ace is 11 in value and when it is a 1 in value, so you don't bust. | |
You can download the matplotlib free from: [url]http://matplotlib.sourceforge.net/[/url] It has, amongst many other things, the module pylab that allows for high quality plotting of data. All you have to do is to feed it a list of x values and the corresponding list of y values calculated from the x … | |
This is my first experience with Python's Tkinter GUI. I want to write a program where the result of an interim calculation is displayed on a label. Later in the program I want to use this result in another calculation by simply clicking on the label. This is what I … | |
I have two similar lists and want to create a new list with just the differences between the two. Is there an existing function or do I have to iterate with a for loop? | |
This simple Python code uses the Tkinter GUI toolkit and the Python Image Library (PIL) to create a program that allows you to grab an image of the display screen (or portion of it) and save it to an image file. Unfortunately, the ImageGrab.grab() method only works on a Windows … | |
The small images you put on buttons and such are nice, but a real pain if you have to attach all those image files to your program. Python's base64 encoding module makes it easy to convert the binary image code to a string that you can simply make part of … | |
Nothing fancy. just shows a simple monthly calendar in a Tkinter label. The trick is to use a fixed font so spaces take up the same area as numbers. | |
Let's say you had a list of full names, where the name would consist of a title, followed by first, middle and last name, or maybe just title and last name. You can sort this list by last name only, by creating a temporary list of sublists of type [last … | |
The snippet shows the use of a list of class instances to form a sortable and searchable database for solvents, or for that matter other chemicals. The list can be expanded and all the needed data added at the same time. | |
Just a short little C program to send beeps to the PC internal speaker. Beep(frequency_hrz, duration_ms) is a WinAPI function as is Sleep(ms). | |
A list of tuples is easy to sort for items in the tuples. This snippet shows you how to sort a (character, frequency) tuple either by character or by frequency. One useful example would be the sorting and display of a list of (player, score) tuples, you might find in … | |
Powers of 2 are closly linked to the position values of binary numbers. The most right position is 2 to the power 0 = 1 then goes to the left with 2 to the power 1 = 2, 2 to the power 2 = 4 and such. If you want … | |
I am looking for a good example of the tarfile module, writing to and reading from an archive. Particularly the highly compressed filename.tar.bz2 format. | |
For the second year running Python has been selected as the Language of the Year by Linux users: [code] Linux Users' Programming Languages of the Year 2008 PHP 115 13.36% Perl 72 8.36% Python 226 26.25% Ruby 46 5.34% C 114 13.24% C++ 129 14.98% Java 106 12.31% Lisp 9 … | |
What Windows Vista program runs the Compiled HTML Help Files (.chm)? Under properties only a meaningless descriptor shows up. | |
What is a closure? I keep reading this word in programming, but never got a good explanation. | |
Does anyone have a good example of a wx.FlexGridSizer() application. | |
Is there a way to verify an exit, if you click on the exit symbol on a wxPython frame? | |
Does Python have a module to display when a file has been last modified? Also, how do you get the file length? | |
Is there a way to do math with hexadecimal numbers in Python? | |
I read somewhere that you should avoid using a leading underline in a variable name. It is supposed to have a special meaning in Python. I can't find anything more detailed. Does anybody know? | |
Does Python have a static variable like C has? I like to avoid a global variable for the usual reasons. Note: A static variable in a C function will retain its last value. | |
How do you loop through an entire year showing each day's date? | |
What is the best way to establish a wxPython event handler for a mouse click, button and so on? I have looked at a number of sample codes and the event handlers differ all over the place. | |
I am fairly familiar with C, but new to Python. Does Python have something like the handy C conditional expression? For example: [code]// C conditional expression x = a ? b : c; // if a is true then x = b else x = c // here used to … | |
Python uses the directories listed in PYTHONPATH to find a module. How can I assure that the module I am importing is on this list of paths? | |
I keep hearing that the eval() function is unsafe. It is a nice function, because you can use it like print eval("2.5*49.7/(23+3.14)") and it will solve the math. Is there any way to protect against some nasty minded person to enter a "os.system(command)" where the command will erase a file … | |
I have the following code, for example: [CODE]price = 50.00 tax = price * 0.08 print "Tax = $",tax # Tax = $ 4.0[/CODE] As you can see there is a space between $ and 4.0. Is there a way to avoid this? I haven't done much Python coding. | |
Couldn't sleep last night, so I was browsing and found the "Starting Python" thingy. I must say Python looks interesting from the examples. I learned C++ in school, Python sure looks easier to understand. Does any one think it's better than C++? |
The End.