[Python-Dev] "as" mania
Paul Moore
p.f.moore at gmail.com
Tue Mar 7 21:49:27 CET 2006
More information about the Python-Dev mailing list
Tue Mar 7 21:49:27 CET 2006
- Previous message: [Python-Dev] "as" mania
- Next message: [Python-Dev] "as" mania
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 3/7/06, Andrew Koenig <ark at acm.org> wrote: > As it turns out, Python has similar ways of decomposing data structures: > > (x, y) = foo > > or > > def bar((x, y)): > # etc. > > and I have sometimes wished I could write > > z as (x, y) = foo > > or > > def bar(z as (x, y)): > # etc. > > However, it's not real high on my list of priorities, and I suspect that > many Pythonists consider these usages to be a frill anyway. For the assignment case, you can do this: >>> foo = (1,2) >>> (x,y) = z = foo >>> x 1 >>> y 2 >>> z (1, 2) >>> Function arguments are not covered by this trick, but def bar(z): (x,y) = z probably isn't too much overhead... (Or did I miss your point?) Paul.
- Previous message: [Python-Dev] "as" mania
- Next message: [Python-Dev] "as" mania
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list