updated pre-PEP: The create statement
Carl Banks
invalidemail at aerojockey.com
Fri Apr 7 00:22:04 EDT 2006
Steven Bethard wrote:
> I've updated the PEP based on a number of comments on comp.lang.python.
> The most updated versions are still at:
>
> http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt
> http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html
>
> In this post, I'm especially soliciting review of Carl Banks's point
> (now discussed under Open Issues) which asks if it would be better to
> have the create statement translated into:
>
> <name> = <callable>("<name>", *<tuple>, **<namespace>)
>
> instead of the current:
>
> <name> = <callable>("<name>", <tuple>, <namespace>)
>
> The former allows the create statement to be applied to a wider variety
> of callables; the latter keeps a better parallel with the class statement.
Meh. I don't think the args, kwargs is a good idea at all, and wasn't
suggesting that. For this construction not to apply to type objects
would be a mistake. I wanted us to consider whether it was a problem
for it not to work in certain useful cases (such as dicts), and whether
it was deal-breaking, and what to do about it if not.
Off the top of my head, a simple way to make this work for both types
and dicts is to have a special static method called __make__ (or
__create__) that is called by this syntax. For type objects, __make__
is a synonym for __new__. For dict, it can call __new__ with the third
argument.
Carl Banks
More information about the Python-list
mailing list