Re: Can we create an_object = object() and add attribute like for a class?
- From: aleaxit@xxxxxxxxx (Alex Martelli)
- Date: Sat, 29 Apr 2006 16:26:16 -0700
Pierre Rouleau <prouleau@xxxxxxxxxxxxxxxxxx> wrote:
...
I can understand the design decision not to give object a __dict__, but
I wonder if i'd be a good idea to have a class that derives from object
and has a __dict__ to be in the standard library. I posted the original
question because I run into this quite often and I just saw a post a
little before mine ("self modifying code") where the idiom was used.
Yes, I do agree it would be a good idea. It's probably too late to add
features to Python 2.5, but I think you should propose a PEP for 2.6.
Standard library module containers seems to be a good place for the
proposed namespace-type, but some discussion might help get some idea of
a consensus about the type's name (is 'namespace' good enough? Is an
__init__ taking arbitrary named arguments, and a __repr__ emitting them,
all the functionality we need -- or should perhaps the type also expose
some other methods delegating to the underlying __dict__, such as
__len__ [[number of attributes]], update, __contains__, __iter__...?).
Alex
.
- References:
- Can we create an_object = object() and add attribute like for a class?
- From: Pierre Rouleau
- Re: Can we create an_object = object() and add attribute like for a class?
- From: Alex Martelli
- Re: Can we create an_object = object() and add attribute like for a class?
- From: Pierre Rouleau
- Can we create an_object = object() and add attribute like for a class?
- Prev by Date: Re: time conversions [hh:mm:ss.ms <-> sec(.ms)
- Next by Date: Re: Generate a sequence of random numbers that sum up to 1?
- Previous by thread: Re: Can we create an_object = object() and add attribute like for a class?
- Next by thread: Re: Can we create an_object = object() and add attribute like fora class?
- Index(es):