Diez B. Roggisch wrote:
> Reinhold Birkenfeld wrote:
>
>> Diez B. Roggisch wrote:
class Foo(type):
def __new__(cls, name, bases, dict):
for k,v in [(k, v) for k,v in dict.items() if callable(v)]:
cls.wrap(k,v,cls.get_directives(v), dict)
So dct is something like a template rather than the __dict__ of the
actual class?
I'd assume that changing the content of a dict would be possible even
after it has been assigned to some object (here, a class).
thanks and best regards
Steffen
--
http://mail.python.org/mailman/listinfo/python-l
Reinhold Birkenfeld wrote:
> Diez B. Roggisch wrote:
>>> class Foo(type):
>>> def __new__(cls, name, bases, dict):
>>>
>>> for k,v in [(k, v) for k,v in dict.items() if callable(v)]:
>>> cls.wrap(k,v,cls.get_directives(v), dict)
>>>
>>> return super(Foo, self).__n
Steffen Glückselig wrote:
> Are wrap and get_directives somehow built-in? I couldn't find
> references to them.
>
> I've noticed, too, that using __new__ I can manipulate the dictionary
> resulting in the behavior I intented.
>
> I'd rather like to know: Why does it work in __new__ but not in
> _
Are wrap and get_directives somehow built-in? I couldn't find
references to them.
I've noticed, too, that using __new__ I can manipulate the dictionary
resulting in the behavior I intented.
I'd rather like to know: Why does it work in __new__ but not in
__init__?
And, stimulated by your response
Diez B. Roggisch wrote:
>> class Foo(type):
>> def __new__(cls, name, bases, dict):
>>
>> for k,v in [(k, v) for k,v in dict.items() if callable(v)]:
>> cls.wrap(k,v,cls.get_directives(v), dict)
>>
>> return super(Foo, self).__new__(self, name, bases, dict)
>
> Th
> class Foo(type):
> def __new__(cls, name, bases, dict):
>
> for k,v in [(k, v) for k,v in dict.items() if callable(v)]:
> cls.wrap(k,v,cls.get_directives(v), dict)
>
> return super(Foo, self).__new__(self, name, bases, dict)
There is a confusion of self and cls
Steffen Glückselig wrote:
> Hello,
>
> I've been experimenting with metaclasses a bit (even though I am quite
> a newbie to python) and stumpled over the following problem in my code:
>
> class Meta(type):
> def __init__(cls, name, bases, dct):
> for attr, value in dct.items():
> if
Hello,
I've been experimenting with metaclasses a bit (even though I am quite
a newbie to python) and stumpled over the following problem in my code:
class Meta(type):
def __init__(cls, name, bases, dct):
for attr, value in dct.items():
if callable(value):
dct[attr] = wrapper(