Viewing Category : python

Post thumbnail of Handle command line arguments with getopt in Python
date29 December 2009
Continue reading Handle command line arguments with getopt in Python

Handle command line arguments with getopt in Python

Here’s a way to use getopt to handle arguments when creating command line applications. It works quite well with the standard help (–help or -h) by showing usage when bad arguments are passed.

Post thumbnail of Store and access passwords safely with python’s keyring
date22 December 2009
Continue reading Store and access passwords safely with python’s keyring

Store and access passwords safely with python’s keyring

Python’s keyring lib supports Windows win32crypto, Mac OS X’s SXKeychain, KDE’s KWallet, Gnome’s keyring, and encrypted or unencrypted password files. When your application wants to store or fetch data from the keyring, it will just work.

Post thumbnail of Just another why Python rules article
date21 December 2009
Continue reading Just another why Python rules article

Just another why Python rules article

It’s all about the design of the language and I agree with the author completely when he says, “Most languages have so much friction and awkwardness built into their design.”

Post thumbnail of Function arguments optional in python
date17 December 2009
Continue reading Function arguments optional in python

Function arguments optional in python

I like it. It’s so simple and flexible. Define it with none, then assign sys.argv in place of argv.

Post thumbnail of Python: Use subprocess to easily catch return values
date13 November 2009
Continue reading Python: Use subprocess to easily catch return values

Python: Use subprocess to easily catch return values

Run system commands or call a sub-process and assign the return value to a variable. This makes it easy to pass the error up to your processes parent.

Post thumbnail of How to debug wxPython errors when your applications crash
date20 October 2009
Continue reading How to debug wxPython errors when your applications crash

How to debug wxPython errors when your applications crash

After your done building your wx objects and you’re ready to show it and call MainLoop(), wrap your main loop where you actually instantiate your gui objects in try/accept statements so that you can really catch any errors by calling the “show_errors()” function to launch a new message window where the errors will get displayed. This lets you catch errors before your whole program dies (causing errors to get lost).

Post thumbnail of Tail a file in Python
date20 October 2009
Continue reading Tail a file in Python

Tail a file in Python

Tail a file in Python

def tail( f, window=20 ):
f.seek( 0, 2 )
bytes= f.tell()
size= window
block= -1
while size > 0 and bytes+block*1024 > 0:

Post thumbnail of wxPython calculator example skeleton code
date17 October 2009
Continue reading wxPython calculator example skeleton code

wxPython calculator example skeleton code

I didn’t find a glade template for this one, but I’m starting to lean away from using a gui builder. It seems more trouble than it’s worth.

Post thumbnail of Focusing on the hard parts of wxPython – layout and events
date17 October 2009
Continue reading Focusing on the hard parts of wxPython – layout and events

Focusing on the hard parts of wxPython – layout and events

I like wxPython a lot more than the other gui tooltkits i’ve tried. I’m finding it really easy to keep it from getting cluttered, and it’s easy to pick up and run with, but there’s some demo’s like this one below, that i’ve seen in various forms all over the place now, that I think are a waste of time. Why would you have a app that has nothing but a menu bar? You wouldn’t, so doesn’t it make sense to get the confusing parts of gui code out of the way? Namely, layout and events.

Post thumbnail of Get a reversed list of command line arguments from sys.argv
date12 October 2009
Continue reading Get a reversed list of command line arguments from sys.argv

Get a reversed list of command line arguments from sys.argv

This is useful if you need to look at the last arguments before deciding what to do, possibly for interoperability with some older code where the order of command line arguments is already set in stone.

 Page 4 of 5 « 1  2  3  4  5 »
Powered by Wordpress   |   Lunated designed by ZenVerse

Valid XHTML 1.0 Transitional