At 07:06 AM 3/9/2007 -0800, Guido van Rossum wrote:
>Those look like use cases for metaclasses, but I don't see how they
>require setting a custom dict *while the class suite is being
>executed*.

The main use case for that is to know what order the items were defined in; 
currently there's no way to achieve that without say, abusing the debugger 
hook.

There are other interesting use cases that could be achieved with a custom 
dictionary, too, now that I'm thinking about it, that currently require at 
least some level of bytecode hacking or string manipulation.  For example, 
there's a Python Cookbook recipe that does propositional logic and works by 
exec'ing code with a custom dictionary after figuring out what names are 
being used by a function body.  With a custom dictionary for the class 
body, that could be done without exec or bytecode inspection.

I personally can see the possibility of using the feature for implementing 
database schema definition forward references (where you need to be able to 
refer to objects that don't yet exist) in a class body.

_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to