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

Sven R. Kunze srkunze at mail.de
Wed Jun 1 09:29:36 EDT 2016


On 01.06.2016 01:10, Greg Ewing wrote:
> Steven D'Aprano wrote:
>> name -> Function(args)
>>
>> will be expanded to:
>>
>> name = Function('name', args)
>
> Another possibility would be to expand it to
>
>    name = Function(args)
>    name.__name__ = "name"
>

Another possibility would be (requiring no syntax change):

     name = function(args)

would always be expanded to

     name = function(args)
     name.__name__ = "name"

or to

     name = function(args)
     # and function.__name__ is already available while function is called


Maybe, somebody knows a reason why a called callable shouldn't know that 
piece of information. I can't think of one.


If there's no assignment, __name__ is None.


Best,
Sven


More information about the Python-ideas mailing list