How to get the actual address of a object

James Mills prologic at shortcircuit.net.au
Fri Oct 24 16:53:29 EDT 2008


On Sat, Oct 25, 2008 at 12:25 AM,  <mujunshan at gmail.com> wrote:
> Thank you,James.
> My original idea was to study all the contents of any object. I can do
> it by using module ctypes.

You can simply just query it's attributes.

Use __dict__ or dir(obj)

Example:

>>> x = 10
>>> dir(x)
['__abs__', '__add__', '__and__', '__class__', '__cmp__',
'__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__',
'__float__', '__floordiv__', '__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__', '__str__', '__sub__', '__truediv__', '__xor__']
>>>

cheers
James

-- 
--
-- "Problems are solved by method"



More information about the Python-list mailing list