[Tutor] IDLE Caching

Alan Gauld alan.gauld at freenet.co.uk
Mon Jul 24 20:04:17 CEST 2006


> class Tree:
>
>    def Tree(self):
>        self.rootNode = None
>    def Tree(self, rootNode):
>        self.rootNode = rootNode

This second definition overrides the first - you cannot do
function overloading based on parameters in Python.

>
> t = Tree()
> n = Node()

These just create instances they don;t excercise any of the
methods - especially since you havenot defined any
constructors. (ie __init__() methods)

> look at this code. Edit this code with IDLE. For example change one 
> of the
> 'self' statement
> in the code. For instance change self => slf then save the file and 
> press
> F5(Run Module)
> It doesn't complain about the code !!! this is my problem.

You aren't executing the faulty code so it won't see the mistake.
You should write a tst program to execute all of the methods in
your classes, then call that function to check the code after each
change.

HTH,

Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list