display object details in django

linkaiyi
Follow

display object details in django

You are really mixing together two different things.

Use dir(), vars() or the inspect module to get what you are interested in (I use builtins as an example; you can use any object instead).

>>> l = dir(__builtins__)
>>> d = __builtins__.__dict__
>>> from pprint import pprint
>>> pprint(l)
['ArithmeticError',
 'AssertionError',
 'AttributeError',
 'BaseException',
 'DeprecationWarning',
...

>>> pprint(d, indent=2)
{ 'ArithmeticError': <type 'exceptions.ArithmeticError'>,
  'AssertionError': <type 'exceptions.AssertionError'>,
  'AttributeError': <type 'exceptions.AttributeError'>,
...
  '_': [ 'ArithmeticError',
         'AssertionError',
         'AttributeError',
         'BaseException',
         'DeprecationWarning',
...
Object has 0 attachments

Was this article helpful?

This article is viewed 10 times!

Recent Viewed Articles

0 Comments

Leave a Comment

Support