At 09:13 PM 7/13/2007 +0200, Thomas Heller wrote:
>playing a little with py3k...
>
>pep3115 mentions that "__prepare__ returns a dictionary-like object
>which is used to store the class member definitions during evaluation
>of the class body."
>
>It does not mention whether this dict-like object is used afterwards
>as the class-dictionary of the created class or not (when the __new__
>method of the metaclass is called).
>
>The sample-code suggests that it would be used as class dict of the
>newly created class (the sample code copies it into a regular dictionary
>before it is passed to the type.__new__ call).
>However, the actual code in the py3k-struni branch (typeobject.c) copies
>the passed in dict again.
>
>In other words, it seems impossible even with pep3115 to use a custom
>subclass of dict as a type's __dict__ member, and afaik it is impossible
>in Python to replace that afterwards.
>
>Is this analysis correct?   Is that the intent of pep3115?  Or could
>the code be changed so that it is possible to supply a custom type dict
>with the metaclass?

I would suggest that we do not intend that the class __dict__ == the 
__prepare__ object, even as the default case.  Otherwise, we have to 
find everything that accesses type dictionaries and make sure they 
can work with other kinds of objects.

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
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