End of file
Alex Martelli
aleaxit at yahoo.com
Mon Oct 11 04:05:17 EDT 2004
Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
> Alex Martelli wrote:
> > Since an immediate instance of type object has no possible use except as
> > a unique, distinguishable placeholder,
>
> That's not true -- you can also assign attributes to such
> an object and use it as a record. (It's not a common use,
> but it's a *possible* use!)
That's not true -- you cannot do what you state (in either Python 2.3 or
2.4, it seems to me). Vide:
protagonist:~ alex$ python2.3
Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x23=object()
>>> x23.foo=23
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'object' object has no attribute 'foo'
>>>
protagonist:~ alex$ python2.4
Python 2.4a3 (#1, Sep 3 2004, 22:25:02)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1640)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x24=object()
>>> x24.bar=24
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'object' object has no attribute 'bar'
>>>
If an object() could be used as a Bunch I do think it would be
reasonably common. But it can't, so I insist that its role as
sentinel/placeholder is the only possibility.
Alex
More information about the Python-list
mailing list