Re: [Tutor] creating Turtle() object using 2 different ways
On 01/31/2014 10:38 PM, Alan Gauld wrote: If you want multiple turtles you should use the first version. Yes, the turtle module has a global turtle that can be used by people playing with a single turtle, and prefere conventional procedural programming style, rather than object-oriented (OO). If you need multiple turtle or prefere OO, then you need to first create an OO turtle as you did, using turtle.Turtle(). (It's all explained in the docs: http://docs.python.org/3/library/turtle.html : << The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. >> ) d ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] creating Turtle() object using 2 different ways
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
[Tutor] creating Turtle() object using 2 different ways
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() t2 = turtle t1.fd(100) t2.goto(-100,100) t2.fd(100) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor