Created
May 26, 2014 20:14
-
-
Save 1337/20ecdb1334203030fd0d to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python2 | |
class Foo(object): | |
x = 3 | |
# [ ] 1. what's wrong with this line? how would you improve it? | |
def func(self, list=[]): | |
# [ ] 2. what is "list" here? what will be appended to it? | |
list.append(list is []) | |
# [ ] 3. what is this method returning? | |
return list | |
class Bar(): | |
x = 5 | |
# [ ] 4. What happens if one class is new-style but the other class is classical? | |
class Baz(Foo, Bar): | |
def func(self, list=[]): | |
# [ ] 5. What is xrange and why should we use it over range? | |
# [ ] 6. What is the value of Baz.x? | |
for i in xrange(Baz.x): | |
# [ ] 7. What is the "yield" ekeyword? | |
# [ ] 8. What is the result of the yield? | |
yield super(Baz, self).func(list) | |
# [ ] 9. What is this syntax called? | |
# [ ] 10. What does the program print? | |
print [x for x in Baz().func()] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment