On 26Mar2015 11:37, Peter Otten <__pete...@web.de> wrote:
You are right. [...]

By the way, in this case you don't need the list at all:

def vartuple(vars):
   return namedtuple("locals", vars)._make(vars.values())

Hmm. Neat. I had not realised that was available.

You'd need "vars.keys()", not "vars", for the first use of "vars", BTW:

 return namedtuple("locals", vars.keys())._make(vars.values())

A remark for the OP: a method name like "_make" would normally be something you would avoid as it is Python convenion that _* names are "private", which in Python usually means subject to arbitrary change and probably not documented; internal implementation mechanisms as opposed to published interfaces.

However, in namedtuple the word "_make" is chosen specificly to avoid clashes with the "named" tuple values (which would normally not start with "_"), and it is explicitly documented.

Thanks Peter!

Cheers,
Cameron Simpson <c...@zip.com.au>

Nothing is impossible for the man who doesn't have to do it.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to