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

Paul Moore p.f.moore at gmail.com
Wed Jun 1 10:06:20 EDT 2016


On 1 June 2016 at 14:29, Sven R. Kunze <srkunze at mail.de> wrote:
> 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.

I'm not sure I follow this proposal. Could you explain a little please?

Given

    x = Symbol('x')

as the current approach, how would you modify that to work with your
proposal? If you could show how you'd write a wrapper function
AutoSymbol, so that

    x = AutoSymbol()

did the same as the above, that'd help me a lot.

Thanks,
Paul


More information about the Python-ideas mailing list