[Python-3000] Metaclasses in Python 3000: Draft 2
Phillip J. Eby
pje at telecommunity.com
Wed Mar 14 21:23:22 CET 2007
At 11:15 AM 3/14/2007 -0700, Guido van Rossum wrote:
>I think this rebuttal isn't strong enough; I'm sure there *will* be
>use cases where a custom prepare method can solve a problem that a
>standard ordered dict couldn't.
For example, a custom prepare could provide access to special method names
to do things in the body, ala Ruby on Rails' ActiveRecord DSL. e.g.:
class SomeRecord(Record, table_name="foo")
x = many(OtherRecord)
Where 'many' is actually an object returned by the special dictionary's
__getitem__. In addition, it might be the case that "OtherRecord" is a
class that doesn't exist yet, and the special dictionary returns a
placeholder object that will serve until a record type with that name is
defined.
This use case doesn't even *need* ordering, but it does need __prepare__.
More information about the Python-3000
mailing list