Created
June 1, 2012 10:52
-
-
Save gennad/2851140 to your computer and use it in GitHub Desktop.
Simple interview question Python
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
# What's wrong in the code? | |
# A: No call to parent __init__. To call, uncomment the code | |
class A: | |
def __init__(self): | |
self._greeting = 'hello' | |
def greet(self): | |
print self._greeting | |
class B(A): | |
def __init__(self): | |
# A.__init__(self) | |
self._greeting_add = ', world' | |
def greet(self): | |
print self._greeting + self._greeting_add # No _greeting because of | |
b = B() | |
b.greet() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment