[Tutor] Reading a Text File with tkFileDialog, askopenfilename+enumerate

Lie Ryan lie.1296 at gmail.com
Mon Feb 16 16:02:16 CET 2009


On Mon, 2009-02-16 at 09:38 -0500, bob gailer wrote:
> Lie Ryan wrote:
> > On Sun, 2009-02-15 at 21:29 +0100, tutor-request at python.org wrote:
> >
> >   
> >> Do you know about sequence unpacking? In an assignment statement, when
> >> the right side is a sequence, the left side can be a list of variables
> >> of the same length as the sequence. Then each sequence element is
> >> assigned to one variable. For example
> >>     
> >
> > <nitpick>
> > The left side can only be a tuple of "names". The tuple unpacking is a
> > little bit of violation of python's object model, since while python's
> > tuple usually contain objects, in tuple unpacking the tuple contains a
> > list of names to be assigned.
> > </nitpick>
> >   
> It's time to take a look at the Language Reference.
> 6.3 Assignment statements.
> assignment_stmt ::= (target_list "=")+ expression_list
> a target list is not a tuple, even though it can look like one.
> So I don't see it as any violation.

Every time I heard about tuple unpacking, everyone always describes the
target_list as tuple. I've never looked at the Language Reference on
this particular case before, so I admit I didn't know that the Language
Reference does make a distinction between the two. So, I'll retract
calling it as violation, tuple and target_list is a completely different
beast.



More information about the Tutor mailing list