archerships: (Default)
2009-02-09 11:32 am
Entry tags:

GEEK: Display method descriptions for all the methods in a Python module

Type the following in the python interpreter:

help()
modules
[name of module]

You should see a list of the methods in the module with their descriptions.

Original: craschworks - comments

archerships: (Default)
2009-01-30 10:08 pm
Entry tags:

GEEK: How to tell where your script is located in Python

Suppose you’re executing a python script in the debugger, and you want to find out where the script you’re executing is located. This should do the trick:

import os
os.path.dirname( os.path.realpath( __file__ ) )

Original: craschworks - comments

archerships: (Default)
2008-05-19 01:00 pm
Entry tags:

GEEK: simple python script to turn image filenames into img elements

It currently doesn’t take any options, though I plan to modify it to read from a filename in addition to stdin. Also, I should modify it to use imagemagick to get the image width and height values, since I don’t think there’s a guarantee that the metadata will store the image dimensions.

Read the rest of this entry » )

Original: craschworks - comments

archerships: (Default)
2007-03-29 02:38 pm

GEEK: How do I request timed user input?

Suppose you want to write a Python program that solicits input from a the user, but goes ahead anyway with a default value if they don't respond in say, 5 seconds. The following snippet of code implements such a thing:

Read more... )