jamesbon
June 3rd, 2013, 04:59 PM
I am learning python and in the example in book talks about multiple superclasses following is the example in book
class Calculator:
def calculate(self,evaluate):
self.value=eval(expression)
class Talker: def talk(self):
print 'Hi, my value is ', self.value
class TalkingCalculator(Calculator,Talker):
pass
But when I type it in terminal
>>> class Calculator(object):
def calculate(self,evaluate):
self.value=eval(expression)
>>> class Talker(object):
def talk(self):
print 'Hi, my value is ', self.value
>>> class TalkingCalculator(Calculator, Talker):
pass
I get following error
>>> TalkingCalcultor.__bases__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'TalkingCalcultor' is not defined
Also the original formatting of my post is lost....how do I get it back here Ubuntu forums have seem to changed a lot...
class Calculator:
def calculate(self,evaluate):
self.value=eval(expression)
class Talker: def talk(self):
print 'Hi, my value is ', self.value
class TalkingCalculator(Calculator,Talker):
pass
But when I type it in terminal
>>> class Calculator(object):
def calculate(self,evaluate):
self.value=eval(expression)
>>> class Talker(object):
def talk(self):
print 'Hi, my value is ', self.value
>>> class TalkingCalculator(Calculator, Talker):
pass
I get following error
>>> TalkingCalcultor.__bases__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'TalkingCalcultor' is not defined
Also the original formatting of my post is lost....how do I get it back here Ubuntu forums have seem to changed a lot...