[Python-ideas] Quick idea: defining variables from functions that take the variable name
Steven D'Aprano
steve at pearwood.info
Wed Jun 1 11:19:46 EDT 2016
On Wed, Jun 01, 2016 at 11:10:19AM +1200, 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"
That priviledges one specific use of the name over all others. You'll
note that I was very careful to describe the use-case as "objects that
need to know their own name" but didn't specify what they did with the
name. Maybe they bind it to self.__name__, but maybe they use self.name
instead. Or they write it to a database. Who knows?
I don't think we should specify what the object does with the name.
--
Steve
More information about the Python-ideas
mailing list