Re: inline metaclasses

2006-07-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, K.S.Sreeram wrote: >> BTW, if that's what gangesmaster is after then it seem to work already. >> Put ``(object)`` after ``X`` and return something, say 'a' and 'b', in the >> getters and the example prints 'a' and 'b'. > > btw, the example seems to work even with old-styl

Re: inline metaclasses

2006-07-04 Thread K.S.Sreeram
Marc 'BlackJack' Rintsch wrote: > K.S.Sreeram wrote: >> The very fact that you can put a loop inside __metaclass__ may be reason >> enough for a one-off metaclass. > > Ah, it's not the loop but the access to the `dict`! You can write loops > at class level too but I haven't found a way to access

Re: inline metaclasses

2006-07-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, K.S.Sreeram wrote: > Marc 'BlackJack' Rintsch wrote: >> But why use a metaclass? If the meta class is only applied to *one* >> class, can't you do at class level whatever the metaclass is doing!? > > The very fact that you can put a loop inside __metaclass__ may be reason

Re: inline metaclasses

2006-07-03 Thread K.S.Sreeram
Marc 'BlackJack' Rintsch wrote: > But why use a metaclass? If the meta class is only applied to *one* > class, can't you do at class level whatever the metaclass is doing!? The very fact that you can put a loop inside __metaclass__ may be reason enough for a one-off metaclass. Here's a contrived

Re: inline metaclasses

2006-07-03 Thread Alex Martelli
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, gangesmaster > wrote: > > > just something i thought looked nice and wanted to share with the rest > > of you: > > > class x(object): > > ... def __metaclass__(name, bases, dict): > > ... print "he

Re: inline metaclasses

2006-07-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, gangesmaster wrote: > just something i thought looked nice and wanted to share with the rest > of you: > class x(object): > ... def __metaclass__(name, bases, dict): > ... print "hello" > ... return type(name, bases, dict) > ... > hello >>>

inline metaclasses

2006-07-03 Thread gangesmaster
just something i thought looked nice and wanted to share with the rest of you: >>> class x(object): ... def __metaclass__(name, bases, dict): ... print "hello" ... return type(name, bases, dict) ... hello >>> instead of defining a separate metaclass function/class, you