Skip to content

Add extended sequence unpacking discussion. #24

Open
@PythonCHB

Description

@PythonCHB

Py3 now has extended sequnce unpacking:

In [30]: x, *y = 1,2,3,4,5

In [31]: x
Out[31]: 1

In [32]: y
Out[32]: [2, 3, 4, 5]

this can be used for a nifty solution to the trigrams looping problem:

In [29]: for follower, *pair in zip(l[2:], l, l[1:-1]):
    ...:     print(pair, follower)
    ...:  

or even better:

In [34]: for *pair, follower  in zip(l, l[1:-1], l[2:]):
    ...:     print(pair, follower)

maybe add to the advanced argument passing section??

See: PEP 3131: https://www.python.org/dev/peps/pep-3132/

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions