Please use ReplyAll to include the tutor list

On 11/03/15 02:00, Jack Potrashitel wrote:
Ok , thanks a lot. But I still in doubts  :(.
  if self.root is None:
          self.root = BinaryNode( value )
      else:
          self.root.add( value )
the object is created  as BinaryNode(value ) only if self.root is None .

That's correct.  But root will only be None on the very first call to add().
After the first call the root attribute will already be set to a BinaryNode
(from the first call) so you just keep calling add() on that same root
instance.

Remember that self.root is part of the object so it will remain active
for as long as the BinaryTree object is active. It exists even between
method invocations.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to