End of file

Greg Ewing greg at cosc.canterbury.ac.nz
Tue Oct 12 05:30:40 CEST 2004


Bengt Richter wrote:
> On Mon, 11 Oct 2004 16:22:28 +1300, Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
>>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!)
> 
> I originally thought that too, but (is this a 2.3.2 bug?):
> 
>  >>> obj = object()
>  >>> obj.x = 1
>  Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
>  AttributeError: 'object' object has no attribute 'x'

I stand corrected! I had forgotten that instances of the
bare object class don't have a __dict__.

So it appears that sentinels are about the only practical
use for them.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list