In "Learning Python," by Lutz and Ascher, there's a table showing different
assignment statement forms. One form shown is list assignment. The authors
give this as an example:
[spam, ham] = ['yum', 'YUM']
I don't see how this is any different than a tuple unpacking assignment:
[color=blue][color=green][color=darkred]
>>> a, b = 1, 2
>>> a, b[/color][/color][/color]
(1, 2)[color=blue][color=green][color=darkred]
>>> [a, b] = [1, 2]
>>> a, b[/color][/color][/color]
(1, 2)
In both instances the names a and b are both mapped to 1 and 2 so why are there
two different forms?
Thanks for any answers.
--
Norvell Spearman
assignment statement forms. One form shown is list assignment. The authors
give this as an example:
[spam, ham] = ['yum', 'YUM']
I don't see how this is any different than a tuple unpacking assignment:
[color=blue][color=green][color=darkred]
>>> a, b = 1, 2
>>> a, b[/color][/color][/color]
(1, 2)[color=blue][color=green][color=darkred]
>>> [a, b] = [1, 2]
>>> a, b[/color][/color][/color]
(1, 2)
In both instances the names a and b are both mapped to 1 and 2 so why are there
two different forms?
Thanks for any answers.
--
Norvell Spearman
Comment