Python printing attributes with no __dict__

Ashley Hughes picture Ashley Hughes · Jan 19, 2013 · Viewed 21k times · Source

I am having trouble with scripting bridge for python

I am trying to list the attributes of the iTunes object

iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")

using

>>> from pprint import pprint
>>> from Foundation import *
>>> from ScriptingBridge import *
>>> iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
>>> pprint (vars(iTunes))

I get back

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: vars() argument must have __dict__ attribute

anyone know how to get around this?

Answer

Ned Batchelder picture Ned Batchelder · Jan 19, 2013

Try dir(iTunes). It's similar to vars, but more directly used with objects.