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

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jun 1 17:01:03 EDT 2016


Steven D'Aprano wrote:
> I'm not proposing any changes to namedtuple at all -- its others who 
> want to change it to take just a single argument and have an wrapper 
> function to specify the field names. I'm against that rather strongly.

I don't think this would be creating TMWTDI. Given the
proposed feature, and a suitable helper, then

   def Foo as NamedTuple('x', 'y', 'z')

would become the *obvious* way to define a named tuple
type. The old way

   foo = namedtuple(something, 'x', 'y', 'z')

would become something low-level that you only use in
special circumstances -- like calling type() directly
to create a class.

-- 
Greg


More information about the Python-ideas mailing list