rekursiver Generator
Von: Thomas Orgelmacher (trash@odbs.org) [Profil]
Datum: 10.10.2009 12:34
Message-ID: <hapnvt$cnu$00$1@news.t-online.com>
Newsgroup: de.comp.lang.python
Datum: 10.10.2009 12:34
Message-ID: <hapnvt$cnu$00$1@news.t-online.com>
Newsgroup: de.comp.lang.python
Hallo zusammen! Ich hoffe 'mal, das ist jetzt keine FAQ. Aber als Python-Neuling komme ich hier absolut nicht weiter: def t(n): yield n if(n < 10): t(n + 1) for i in t(0): print(i) Warum tut das so nicht? Wenn ich das richtig verstanden habe, wird der komplette Zustand einer Funktion bei einem yield gesichert und beim nächsten "Aufruf" wird nach dem yield weitergemancht. Das funktioniert auch soweit (ich habe testhalber 'mal nach jeder Zeile ein print eingefügt), aber die Rekursion funktioniert nicht. Gruß, Orgel -- I have seen things you lusers would not believe. I've seen Sun monitors on fire off the side of the multimedia lab. I've seen NTU lights glitter in the dark near the Mail Gate. All these things will be lost in time, like the root partition last week.[ Auf dieses Posting antworten ]
Antworten
- Diez B. Roggisch (10.10.2009 12:39)
- Thomas Orgelmacher (10.10.2009 13:55)
- Diez B. Roggisch (10.10.2009 15:22)
- Georg Brandl (10.10.2009 18:31)
- Thomas Mlynarczyk (10.10.2009 22:00)
- Marek Kubica (11.10.2009 10:46)
- Thomas Orgelmacher (11.10.2009 13:15)
- Dietmar Schwertberger (11.10.2009 17:26)
- Mick Krippendorf (11.10.2009 18:30)
- Mick Krippendorf (10.10.2009 14:11)
- Thomas Orgelmacher (10.10.2009 15:35)
