Py2K wishes

Paul Prescod paul at prescod.net
Thu Dec 30 04:43:59 EST 1999


Skip Montanaro wrote:
> 
> Maybe I'm way out of context here, but can't you subclass on-the-fly with
> something like:
> 
>     def func(o):
>         class sub(o.__class__):

The problem is that what I want is so much simpler than subclassing.

>>> orig = object()
>>> orig.foo = 5

>>> newobj = object()
>>> newobj.bar = 6
>>> newobj.__fallback__ == orig
>>> print newobj.foo, newobj.bar
(5,6)

I don't claim that this feature would save me so many hours as to even
justify the amount of time I've spent explaining it. It just struck me
as being in the same category as, for example, importing where you see
the language do something magical (finding a file and loading it as a
module) and then find out that the magic is based on simpler concepts
that are each independently available and overridable. 

 Paul Prescod






More information about the Python-list mailing list