• PatoNegro

    @JonB, thanks. That is an interesting option. That option implies that files in site-packages take precedence over the production files. So much to learn about the Python language and the Python environment.

    I am also trying to learn a little SWIFT to teach introductory concepts. For a starter I am using SWIFT Playgrounds on my iPad. I have XCode installed on my Mac Mini. However it seems more complicated than Python for teaching 4th to 6th grade students.

    posted in Pythonista read more
  • PatoNegro

    @mikael, thanks for the heads-up. I did not think of checking GitHub.

    One new observation is that both turtle.py and turtle2.py for Pythonista use pen_dict as the variable name. The turtle.py file on svn.python.org uses pendict as the variable name. For now I am simply using the turtle2.py version for my class preparation.

    posted in Pythonista read more
  • PatoNegro

    I am trying to learn Python to teach it to children. I am using the book “Python for Kids” by Jason Brigs. Chapter 4 introduces Drawing with TURTLES. The following code is entered in the Python console:
    import turtle
    t = turtle.pen()

    Entering it in Pythonista that I purchased for my iPad Pro gave me the following error message.
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/var/containers/Bundle/Application/985F9C6D-5025-471A-AFF4-C482CEB52E0C/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/turtle.py",
    line 1203, in pen
    pen.update(pen_dict)
    NameError: name 'pen_dict' is not defined

    Researching the forum I found the turtle2.py file - https://forum.omz-software.com/topic/5014/shape-method-for-turtle-py
    Comparing the two files I found the following differences.
    Pythonista turtle.py
    1201 if pen is None:
    1202 --- pen = {}
    1203 pen.update(pen_dict)
    Tries to update pen_dict even though it may not exist

    Pythonista turtle2.py
    1231 if pen is None:
    1232 ---- pen = {}
    1233 if not pen_dict is None: # Checks to see if pen_dict exists
    1234 ---- pen.update(pen_dict)

    I did some more research and found a complete turtle.py .
    from: https://svn.python.org/projects/python/tags/r32/Lib/turtle.py
    2396 if not (pen or pendict):
    2397 ---- return _pd
    2398 Use the isinstance command to determine if pen is a dictionary type.
    2399 if isinstance(pen, dict):
    2400 ---- p = pen
    2401 else:
    2402 ---- p = {}
    2403 p.update(pendict)

    SUMMARY:
    Since there is a bug in the current Pythonista turtle.py file and since the turtle2.py file added shapes, I recommend that the turtle2.py be considered as a replacement/upgrade after verifying that it implements the other classes and functions of the current Pythonista turtle.py file.

    Side-Note: I am a retired computer programmer with extensive OO experience, especially with VB.NET.

    Update 2018_08_16 - - - Found my problem - - -
    There are three lines in the first turtle example.
    import turtle
    t = turtle.pen()
    t = forward(50)
    The last line gave an error after fixing the pen.update(pen_dict) error because t did not have a forward() method.
    Why? Well, the problem was simply the fact that I was calling the pen() function of the turtle module. After looking closely at the book, I realized that the code should be t = turtle.Pen(). That is, I needed to use an upper case P which meant that t was creating an instance of the Pen() class. When I corrected my mistake, the code ran from the console using the current Pythonista turtle.py module.

    Ah, so much to learn about Python. However, I believe that the bug that I described above is real.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!