How do you write this in python
Ali
alikakakhel3 at hotmail.com
Wed Oct 6 18:41:17 EDT 2004
ok that makes some sense.
>You can assign properties whenever you want - it does not have to be
>done in the __init__ method.
This cought my attention so I entered this into the shell to try to do
this very thing:
>>>class card:
def setProperties(self, name, email):
self.name = name
self.email = email
def show(self):
print self.name + '/' + self.email
>>>ali = card('ali','ali at ali.com')
I got the following error:
Traceback (most recent call last):
File "<pyshell#27>", line 1, in ?
ali = card('ali','ali at ali.com')
TypeError: this constructor takes no arguments
I thought you said I could assign the properties at any place so I
defined them in the setProperties() method. What did I do wrong?
More information about the Python-list
mailing list