pre-PEP: The create statement
Ron Adam
rrr at ronadam.com
Thu Apr 6 11:27:50 EDT 2006
> Abstract
> ========
>
> This PEP proposes a generalization of the class-declaration syntax,
> the ``create`` statement. The proposed syntax and semantics parallel
> the syntax for class definition, and so::
>
> create <callable> <name> <tuple>:
> <block>
>
> is translated into the assignment::
>
> <name> = <callable>("<name>", <tuple>, <namespace>)
>
> where ``<namespace>`` is the dict created by executing ``<block>``.
> The PEP is based on a suggestion [1]_ from Michele Simionato on the
> python-dev list.
I'll have to think on this one a bit. So I'm undecided for now.
Could it possibly use the 'as' keyword?
create <callable> <tuple> as <name>:
<block>
It has also been suggested that a pattern where functions and classes
are assigned be used. Possibly something like...
name = class():
<block>
name = def():
<block>
name = create():
<block>
Or it could be...
name = object():
<block>
This is a bigger change than adding the create keyword, (definitely not
a pre-P3k item), and I'm not sure if it fits your use case, but it does
allow for a larger variety of types without adding additional keywords.
Cheers,
Ron
More information about the Python-list
mailing list