Created
September 24, 2011 16:35
-
-
Save zoranzaric/1239520 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = ('val', 1, 1) | |
b = ('list', 2, [a, a]) | |
c = ('val', 3, 2) | |
l = [a,b,a,c] | |
def gen(l, known): | |
for type, id, val in l: | |
if id not in known: | |
if type == 'list': | |
for inner_val in gen(val, known): | |
yield inner_val | |
yield val | |
known = set() | |
for x in gen(l, known): | |
print x | |
# Hier erwarte ich jetzt die Ausgabe: | |
# 1 | |
# 2 | |
# 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment