On Sun, 25 Mar 2007 11:58:00 +0200, Peter Otten wrote:
>> But it doesn't work:
>>
> vint = verbosify_nclass(int)
> vint(42)
>> Calling constructor __new__ ...
>> Traceback (most recent call last):
>> File "", line 1, in
>> File "", line 6, in __new__
>> TypeError: object.__new__(VCla
Steven D'Aprano wrote:
> Here's a simple class-factory function that returns a sub-class of the
> old-style class it is passed.
>
> def verbosify_oclass(klass):
> """Returns a verbose sub-class of old-style klass."""
> class VClass(klass):
> def __init__(self, *args, **kwargs):
> print "Calling i
Here's a simple class-factory function that returns a sub-class of the
old-style class it is passed.
def verbosify_oclass(klass):
"""Returns a verbose sub-class of old-style klass."""
class VClass(klass):
def __init__(self, *args, **kwargs):