On Thu, May 05, 2005 at 01:35:09AM -0700, Max Derkachev wrote:
> Good day to all.
>
> Some time ago I'd been playing with a framework which uses dynamic
> class creation havily. Say, I could do:
>
> #well, try this with the new-style class
> class A(object):
> pass
>
> # the new-style __dic
John Machin wrote:
> >>> A.foo
> 123
Oh, I've been a little dumb to forget about it :)
Thanks.
Max.
--
http://mail.python.org/mailman/listinfo/python-list
Max Derkachev wrote:
[snip]
> #well, try this with the new-style class
> class A(object):
> pass
>
> # the new-style __dict__ is a dictproxy object
> A.__dict__[meth_name] = lambda self: type(self)
> >>Traceback (most recent call last):
> >> File "", line 1, in ?
> >>TypeError: object does not
Do you mean setattr?
setattr(A, meth_name, lambda self: type(self))
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list