Python Forum

Full Version: Turtle / turtle question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I know that Turtle is python v2 and turtle is v3.
To import is use this:
from turtle import Turtle
t =  Turtle()
and i can do everything i want.

But is that state of the art? If i do:
import turtle as t
I can do a lot of things, but many are missing, eg. the screen.title() option.
"import turtle as t" seems to be some strange mix with many attributes
referring to the v2 "Turtle" (capital), so it seems.

Does anybody have a clear view on the logic behind all this.
Why would i have to refer to a legacy Turtle when using turtle?
Huh
thx,
Paul
If you do import turtle as t, then t is the turtle module. If you do import turtle; t = turtle.Turtle(), then t is an instance of the turtle.Turtle class. The module and the class have different members.

Things are somewhat complicated by the fact that the turtle module implements a procedure-oriented interface (without explicit creation of a Turtle instance) and an object-oriented interface. If you want to be consistent with the rest of python, choose the the object-oriented interface, that is to say, create your own Turtle instance and work with it (that's where you say that you can do anything you want).
(Oct-04-2020, 08:48 AM)Gribouillis Wrote: [ -> ]If you do import turtle as t, then t is the turtle module. If you do import turtle; t = turtle.Turtle(), then t is an instance of the turtle.Turtle class. The module and the class have different members.

Things are somewhat complicated by the fact that the turtle module implements a procedure-oriented interface (without explicit creation of a Turtle instance) and an object-oriented interface. If you want to be consistent with the rest of python, choose the the object-oriented interface, that is to say, create your own Turtle instance and work with it (that's where you say that you can do anything you want).

Crystal clear!
thx,
Paul