Python: Wann kann ich einen Generator auspacken? [Duplikat]

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Python: Wann kann ich einen Generator auspacken? [Duplikat]

by Anonymous » 17 Jan 2025, 10:58

Wie funktioniert es unter der Haube? Ich verstehe den Grund für die folgenden Fehler nicht:

Code: Select all

>>> def f():
...     yield 1,2
...     yield 3,4
...
>>> *f()
File "", line 1
*f()
^
SyntaxError: invalid syntax
>>> zip(*f())
[(1, 3), (2, 4)]
>>> zip(f())
[((1, 2),), ((3, 4),)]
>>> *args = *f()
File "", line 1
*args = *f()
^
SyntaxError: invalid syntax

Top