Exceptions, assigning a tuple

Georgy Pruss see_signature__ at hotmail.com
Sun Nov 23 18:05:12 EST 2003


"Mel Wilson" <mwilson at the-wire.com> wrote in message news:cqov/ks/Kjxa089yn at the-wire.com...
|
|    The use of tuple unpacking that surprised me most is in
| function arguments:
|
|
| Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
| Type "help", "copyright", "credits" or "license" for more information.
| >>> def f ( (a,b) ):
| ...     print a, b
| ...
| >>> x = (1,2)
| >>> f(x)
| 1 2
| >>>
|
|    It almost looks like Prolog unification (but isn't
| really.)
|
|         Regards.        Mel.

That's a trick! Is it used? Does anybody use assignments like this:
(a,((b,(c,)),d,e)) = (1,((2,(3+4,)),5,6))

-- 
Georgy Pruss
E^mail: 'ZDAwMTEyMHQwMzMwQGhvdG1haWwuY29t\n'.decode('base64')







More information about the Python-list mailing list