swampy.TurtleWorld not working in python 3.4 -


i m learning python using thinkpython book, using python 3.4 , anaconda ide. part of need continue install module called swampy. installed using pip, worked well. importing module worked tkinter, can't use of functions in module. checked lib folder, swampy there , functions in swampy folder. can't figure out why not working. please need help. if question isn't clear enough please let me know. have included code tried run , error message each time try running it

the code try run (page 29, chapter 4 of think python version python 3.4)

import tkinter import swampy world = swampy.turtleworld bob = turtle() print(bob) wait_for_user() 

error message got

traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "c:\users\mbaka1\anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 682, in runfile     execfile(filename, namespace)   file "c:\users\mbaka1\anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 85, in execfile     exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)   file "c:/users/mbaka1/documents/python scripts/test.py", line 28, in <module>     world = swampy.turtleworld attributeerror: 'module' object has no attribute 'turtleworld' 

the book shows these directions if you've downloaded source code:

from turtleworld import * world = turtleworld() bob = turtle() print(bob) wait_for_user() 

if want run code after installing pip, should work:

from swampy.turtleworld import * world = turtleworld() bob = turtle() print(bob) wait_for_user() 

the reason you're doing isn't working because turtleworld module within swampy package, contains functions same name, i.e. turleworld. when import swampy , try calling swampy.turtleworld you're trying call module rather function.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -