[Python-Dev] Definining properties - a use case for class decorators?
Michael Hudson
mwh at python.net
Mon Oct 24 12:24:34 CEST 2005
Nick Coghlan <ncoghlan at gmail.com> writes:
> Josiah Carlson wrote:
>> You can get the same semantics with...
>>
>> class NAME(_(TYPE), ARGS):
>> BLOCK
>>
>> And a suitably defined _. Remember, not every X line function should be
>> made a builtin or syntax.
>
> And this would be an extremely fragile hack that is entirely
> dependent on the murky rules regarding how Python chooses the
> metaclass for the newly created class.
Uh, not really. In the presence of base classes it's always "the type
of the first base". The reason it might not seem this simple is that
most metaclasses end up calling type.__new__ at some point and this
function does more complicated things (such as checking for metaclass
conflict and deferring to the most specific metaclass).
Not sure what the context is here, but I have to butt in when I see
people complicating things which aren't actually that complicated...
Cheers,
mwh
--
There's an aura of unholy black magic about CLISP. It works, but
I have no idea how it does it. I suspect there's a goat involved
somewhere. -- Johann Hibschman, comp.lang.scheme
More information about the Python-Dev
mailing list