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.
Live forever or die trying
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.
Filed in programming, python | Permalink | Comments (0) »
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__ ) )
Filed in programming, python | Permalink | Comments (0) »
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.
Filed in blogging, exiftool, python | Permalink | Comments (0) »
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 ObjectModel import FrontBase fbc = FrontBase.FrontBaseConnection() for m in fbc.getSQLResultsDictionaryIter("select * from MManager"): for k, v in m.items(): print "%s : %s" % (k,v)
returns this:
joined: 2003-05-06 12:00:00 encryptedpassword : D2A55F132c83686A2a3sF9a4F5b7g0D5aCBFaB05 loginname : samplemember mailtroubleindex : 0 firstname : Sample lastname : Member previouslogin : 2006-06-09 16:21:26 fullname : Sample Member logincount : 176 Traceback (most recent call last): File "", line 2, in ? File "build/lib.darwin-8.6.0-Power_Macintosh-2.4/objc/_convenience.py", line 600, in
It's barfing on the primarykey field from the first row returned. For some reason, the adaptor code doesn't want to print the primarykey. The primarykey object is of the following type:
print type(m['primarykey'])
I listed the methods for the m['primarykey'] object as follows:
methodList = [method for method in dir(m['primarykey'])
for method in methodList
FILE = open(“test2″,”w”
FILE.write(method)
FILE.write(“\n”)
FILE.close()
Among the 363 methods were returned, hexString() looked promising.
m['primarykey'].hexString().__str__
Filed in frontbase, geek, programming, python | Permalink | Comments (0) »
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
Filed in geek, python | Permalink | Comments (0) »
© 2012 crasch | Powered by WordPress | plaintxtBlog theme by Scott | Sponsor: Premium Seven Jeans | Valid XHTML & CSS | Posts RSS & Comments RSS