17aug12 Well, what follows is a bit cryptic. These are three attempts to find the optimal starting point for a turtle circle rtica based on drawing polygons with input poly(, , ) This lesson is also good for understanding the differences between "import" "import *" and whether the helper in turn imports the turtle stuff itself or not. If you're impatient, try this: ======journal======= westkill-3:circle gfrancis\$ python Python 2.7 (r27:82508, Jul 3 2010, 20:17:05) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from circ import * >>> poly(4,50,90) =======end========== and look at square-circle.png of what you should see. Test your comprehension: how was morepolys.png made? The polycircle.py illustrates a theorem, what is it? Here is the code for it >>> poly(4,124,90) = square >>> poly(8,62,45) = octagon >>> poly(16,31,22) = 16-gon >>> poly(32,15,11) = 32-gon Hint: What is constant from one approximation to of a circle to the next? 6sep11 if circ.py does an "from turtle import *" and >>>import circ then >>> dir() adds "circ", while dir(circ) shows all of dir(turtle) as well. >>> circ.forward(100) is actually forward(100) On the other hand >>> circ.poly(4,120,90) works Next, what happens if circl.py does an "import turtle"? Then, you have to >>> circl.turtle.forward(100) Now >>> circ.poly(4,120,90) has no idea what fd means. Suppose crcl.py contains NO imports, just the code that assumes that fd and rt are in the dictionary. Even though >>> from turtle import * >>> fd(100) works fine >>> import crcl >>> crcl.poly(4,120,90) does not .... so, the dictionaries are not merged. And it doesn't help that you >>> from crcl import * >>> poly(90,120,90) still won't work. This is illogical. Further, it seems that in order to use >>> turtle.__doc__ it has to be >>> import turtle earlier. 31aug11 Here is an experiment for learning an imported module "on the hoof", as it were. Python offers several tools. The dir() tool. The foo.__doc__ The inspect.py module. In particular >>> inspect.getargspec(turtle.dot) ArgSpec(args=['size'], varargs='color', keywords=None, defaults=(None,)) dir() dir.__doc__ import turtle pytree.__doc__ gives the """ description (that's double underscores) dir(pytree) gives the vocabulary