Tuple assignment

bearophile bearophileHUGS at lycos.com
Thu Oct 7 12:14:12 PDT 2010


Juanjo Alvarez:

> Python has the special symbol "_" which is used exactly as
> a no-op (you could call it "foo" it you wanted, but "_"
> doesn't create new memory assignments) so you can expand
> arbitrary tuples without creating new symbols:
> 
> a, b, c, _ = ('tuple', 'of', 'three')

This is false both in Python2 and Python3.

In Python3 there is the syntax:
a, *bc = ('tuple', 'of', 'three')

That's semantically similar to the proposed D syntax:
auto record(a, bc...) = record('tuple', 'of', 'three')

Bye,
bearophile


More information about the Digitalmars-d mailing list