[Python-Dev] Tuple/list assignment question

"Martin v. Löwis" martin at v.loewis.de
Wed Aug 4 06:51:28 CEST 2004


Greg Ewing wrote:
> Having to explicitly slice off the part you want to unpack not only
> seems inefficient (constructing an intermediate list or tuple just to
> immediately unpack it and throw it away) it also tends to obfuscate
> what is going on.

Of course, the proposed syntax does not change this. Compare

a,b,c = foo()[:3]

to

a,b,c,*_ = foo()

In either case, the extra fields obfuscate things, and in either
case, a second tuple is created. In the latter case, the tuple
is even stored in a variable.

Regards,
Martin


More information about the Python-Dev mailing list

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant