And so says Hugh Perkins on 13/03/06 18:59...
> I guess the thing that I find tricky in Python is that it is possible to
> accidentally add unintended properties to a class by misspelling the
> intended one, and sometimes it's tricky to catch this.
It is certainly possible, but it doesn't happen as often as you'd think.
Also - self.foo = bar assigns to the instance, not the class.
> For example (my
> Python syntax might be a little rusty..):
> class MyClass():
> def __constructor__(self, name):
> self.name <http://self.name> = name
> def PrintName(self):
> print "My name is " + self.myname
> myobject = new MyClass("Tom")
> C:\> python test.py
> My name is
No, it gives an AttributeError exception. You only "create" new
attributes with an assignment.
And you can constrain even that using slots. If you're interested,
contact me in private :-) otherwise, just record the fact that it's
possible. (A class with slots makes all attribute assignments fail
unless the attribute name is in the slots list.)
So many of our dreams at first seem impossible,
then they seem improbable, and then, when we
summon the will, they soon become inevitable.
GNU: never give up freedom http://www.gnu.org/
vos-d mailing list