Skip to content

Instantly share code, notes, and snippets.

@gennad
Created June 1, 2012 10:52
Show Gist options
  • Save gennad/2851140 to your computer and use it in GitHub Desktop.
Save gennad/2851140 to your computer and use it in GitHub Desktop.
Simple interview question Python
# 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