[Python-ideas] Unpack of sequences

M.-A. Lemburg mal at egenix.com
Wed Aug 29 20:16:10 CEST 2012


Alexander Belopolsky wrote:
> On Wed, Aug 29, 2012 at 1:28 PM, Guido van Rossum <guido at python.org> wrote:
>> it's probably better not to add a language feature and let users write
>> what they want.
> 
> How can users write a solution that does not require repetition of
> variable names? Of course I can write something like
> 
> a, b, c = [m.get(x) for x in ('a', 'b', 'c')]
> 
> but when I have more and longer names, this gets tedious.

>>> d = dict(a=1, b=2, c=3)
>>> locals().update(d)
>>> a
1
>>> b
2
>>> c
3

Not that I'd recommend doing this, but it's possible :-)

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Aug 29 2012)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
2012-10-23: Python Meeting Duesseldorf ...                 55 days to go
2012-08-28: Released mxODBC 3.2.0 ...             http://egenix.com/go31
2012-08-20: Released mxODBC.Connect 2.0.0 ...     http://egenix.com/go30

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/



More information about the Python-ideas mailing list