I am trying to use a book on python, and I understand that from turtle import *
imports everything into the current namespace while import turtle
just brings the module in so it can be called as a class. When I try the latter, though, it breaks.
>>> import turtle
>>> t = turtle.pen()
>>> t.pen.forward(10)
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
t.pen.forward(10)
AttributeError: 'dict' object has no attribute 'pen
However, using from turtle import*
, assigning pen
to an object and typing command forward
works fine. This is not what the book says to do, but it is the only thing that works. What is happening?