On 31/01/14 10:09, Ian D wrote:
Hi

Another quickie.

I can create turtle objects (if that's the correct terminology) using 2
different ways, both work.

t1 = turtle.Turtle()
  or
t2 = turtle

But which is the best practice... and why?




import turtle

t1 = turtle.Turtle()

This creates an instance of a turtle

t2 = turtle

This is just a reference to the turtle module

t1.fd(100)

This moves your specified instance of a turtle

t2.goto(-100,100)
t2.fd(100)

These move the global turtle object using the
module level functions.

If you want multiple turtles you should use
the first version.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
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