unpacking lists (there's more than one way to do it!)

Corrado Gioannini gioco at nekhem.com
Wed Jan 16 10:41:42 CET 2002


On Tue, Jan 15, 2002 at 10:15:29PM -0500, Roy Smith wrote:
> I often use the [] construct when unpacking a long list:
> 
> class foo:
>    def __init__ (self, values):
>       [self.a,
>        self.b,
>        self.c,
>        self.d,
>        self.e,
>        self.f,
>        self.g] = values
> 
> If I left out the []'s, I'd have to put \'s at the end of each line, which 
> I find rather ugly.

well, the same goes by using ()'s:
class foo:
    def __init__ (self, values):
        (self.a,
         self.b,
         self.c,
         self.d) = values
"""
    The preferred way of wrapping long lines is by using Python's
    implied line continuation inside parentheses, brackets and braces.
"""
taken from http://python.sourceforge.net/peps/pep-0008.html d:)

C.
-- 
Corrado Gioannini
<gioco at nekhem.com>

"Thought is only a flash between two long nights,
                                         but this flash is everything."
                                                          (H. Poincaré)
		      




More information about the Python-list mailing list