Python-URL! - weekly Python news and links (Nov 17)

Steve Holden steve at holdenweb.com
Tue Nov 18 12:22:54 EST 2008


rurpy at yahoo.com wrote:
[...]
> One of the reasons I would like to formulate a good
> model of an object's value and type is so that I could
> try to offer something better.  Responses like yours
> are significantly demotivating.

And yet you argue when people try to explain to you that objects don't
*have* values, objects *are* values. Objects have attributes, which are
references to other values. One of an object's attributes is its type.

You seem to be hunting for the ineffable "primitive value" that has no
other attributes. Such a thing doesn't exist.

>>> type(object) is type
True
>>> type(type) is type
True
>>> isinstance(type, object)
True
>>> isinstance(object, type)
True
>>> dir(object)
['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__',
'__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
'__setattr__', '__str__']
>>> object.__class__
<type 'type'>
>>> type.__class__
<type 'type'>
>>> dir(type)
['__base__', '__bases__', '__basicsize__', '__call__', '__class__',
'__cmp__', '__delattr__', '__dict__', '__dictoffset__', '__doc__',
'__flags__', '__getattribute__', '__hash__', '__init__', '__itemsize__',
'__module__', '__mro__', '__name__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__str__', '__subclasses__',
'__weakrefoffset__', 'mro']
>>> type.__bases__
(<type 'object'>,)
>>> object.__bases__
()
>>>

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list