Hi, Martin. A few hints. I believe what you're looking for is what we Pythonistas call "introspection." Python is a dynamic language. This means that all Python objects are basically dicts, and all dicts are basically strings. ;-) Therefore, you can introspect any object at run-time. You can even do other magical stuff like dynamically (at run-time) generate running code!
Try out Python's built-in dir function. It shows you a list of an object's attributes and methods. I hope this will help you: bash-3.2$ python Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> o = 5 >>> print dir(o) ['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'conjugate', 'denominator', 'imag', 'numerator', 'real'] >>> Good luck! Raj On Dec 9, 2009, at 11:19 AM, Martin Casey wrote: > sorry if this seems like a simple question... i'm struggling a bit > with printing the contents of a (python) object (returned from the > data store) to the screen, just to see what's in it, much in the way > that you might "print_r" on an array in php. i've attempted to use > the pprint (pretty print) functions, which generally reveal some > details but not in a particularly readable fashion. may i ask what > other people use? > > Best - > > Martin Casey > 512.484.9690 /c > [email protected] /e > > -- > > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
