Entries Tagged as 'python'

Monday, February 9th, 2009

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.

Friday, January 30th, 2009

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__ ) )

Monday, May 19th, 2008

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.

Tuesday, October 10th, 2006

Geek: notes to myself

I'm trying to select and display some rows from a FrontBase table. I'm accessing the table via a python script, which talks to the database via a pyobjc interface to an Objective-C adaptor to FrontBase. “getSQLResultsDictionaryIter” is a method which returns an array of dictionaries containing the results. For example, this snippet: import objc import [...]

Wednesday, November 10th, 2004

GEEK: Open a webbrowser from a python script

webbrowser.py allows you to open a url in an external browser (such as Firefox) from within a python script.  However, if you don't have the BROWSER environment variable set, you will get an error. To get it to work you have to do the following: % env | grep BROWSER BROWSER=open export BROWSER