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

Ian Foote ian at feete.org
Tue May 31 19:46:36 EDT 2016

On 01/06/16 00:31, Greg Ewing wrote:
> 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.

This is the first syntax I've seen in this thread that seems reasonably
intuitive and pythonic. I don't mind particularly the keyword used (def
or something else), but this structure draws the right parallels in my mind.

Ian F

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160601/1d7090d2/attachment.sig>

More information about the Python-ideas mailing list