[Python-ideas] Quick idea: defining variables from functions that take the variable name

Greg Ewing greg.ewing at canterbury.ac.nz
Tue May 31 19:31:52 EDT 2016

Steven D'Aprano wrote:

> I know that *technically* def is 
> an assignment (a name binding) but it doesn't look like one. It looks 
> like a definition or declaration.

Well, the use cases we've been considering are effectivly
definitions, they just don't look like it because we don't
have a syntax that generalises the definitioniness of
'def' and 'class'.

 > To me, I don't think def is a good match because def doesn't have a left
 > and right hand side. Assignment does.

Maybe that means assignment isn't a good model for the
new syntax?

Maybe it should be more like:

    def Symbol x

If you want to give it args, you do

    def Symbol x(args)

The idea is that this is modelled after

    class name(args):

with the keyword 'class' replaced by another keyword
together with the type of thing you're defining.


More information about the Python-ideas mailing list