I run this code:
[EMAIL PROTECTED] /tmp]# vi Lover.py
class lover:
def __init__(self,man='man',woman='woman'):
self.lover='When a '+man+' love a '+woman
print self.lover
def smile(self):
print self.lover+':-)'
def kiss(self):
print self.lover+':-)(-:'
[EMAIL PROTECTED] /tmp]# python
Python 2.1 (#1, Apr 18 2001, 17:55:45)
[GCC 2.95.3 19991030 (prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>>from Lover import lover
>>>John_and_Rose=lover()
When a man love a woman
>>>John_and_Rose.smile()
when a man love a woman:-)
>>>John_and_Rose.kiss()
when a man love a woman:-)(-:
>>>John_and_Rose.sayGoodBye()
Traceback (most recent call last):
File "", line 1, in ?
AttributeError: lover instance has no attribute 'sayGoodBye'
>>>John_and_rose.JohnAskWhy()
Traceback (most recent call last):
File "", line 1, in ?
AttributeError: lover instance has no attribute 'JohnAskWhy'
>>>class RoseLoveSomebodyElse:
def sayGoodBye(self):
print "Let's say goodbye tonight."
>>>lover.__bases__+=(RoseLoveSomebodyElse,)
>>>John_and_Rose.sayGoodBye()
Let's say goodbye tonight.
>>>
a error occur
IronPython.Objects.PythonAttributeError: 'lover' object has no
attribute 'sayGoodBye'
at IronPython.Objects.Ops.GetAttr(Object o, String name)
at input_8.Run(Frame frame)
at IronPython.Hosting.PythonEngine.DoOneInteractive(Frame topFrame)
at IronPython.Hosting.PythonEngine.RunInteractive()
_______________________________________________
users-ironpython.com mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com