turtle: properties instead of setters/getters ?

Hi, turtle module is nice way to introduce to Python, but, if I want to increase x by 10, I have to write t.setx( t.xcor() + 1) which is uglier (and not beginner friendly) than common: t.x = t.x + 1 beginners tend to forget () after xcor and so on... This could be achieved with several property <https://docs.python.org/3/library/functions.html#property>/decorator lines Would it be possible for Py 3.5? :) ps.: I teach programming games, and more robust expressions (for collision checking) would look cleaner: if ball.x-5 > box.x-10 and ball.x+5 < box.x+10: ball.x =100 instead of if ball.xcor()-5 > box.xcor()-10 and ball.xcor()+5 < box.xcor()+10: ball.setx( 100 ) pps.: I don't know how would default turtle instance behave could I then write x = x + 1 instead of setx( xcor() + 1) ? -- Jurgis Pralgauskis tel: 8-616 77613; Don't worry, be happy and make things better ;) http://galvosukykla.lt

The same would apply to many other properties: y heading position speed pensize color shape shear tilt visible maybe sth else.. On Mon, Apr 27, 2015 at 6:19 PM, Jurgis Pralgauskis < jurgis.pralgauskis@gmail.com> wrote:
-- Jurgis Pralgauskis tel: 8-616 77613; Don't worry, be happy and make things better ;) http://galvosukykla.lt

As I started with proposals, there is one more "mouse move" event: onpointed() (or variables mouse.x, mouse.y accessible as in Processing.org) seems quite easily achievable http://stackoverflow.com/questions/22925599/mouse-position-python-tkinter On Mon, Apr 27, 2015 at 6:36 PM, Jurgis Pralgauskis < jurgis.pralgauskis@gmail.com> wrote:
-- Jurgis Pralgauskis tel: 8-616 77613; Don't worry, be happy and make things better ;) http://galvosukykla.lt

On Mon, Apr 27, 2015 at 12:19 PM, Jurgis Pralgauskis < jurgis.pralgauskis@gmail.com> wrote:
I doubt very much that anything is going to happen with the official Turtle module unless the person that actually wrote it decides it's worth looking into. Following a suggestion you made on this list, I submitted a patch ( http://bugs.python.org/issue23660) about 6 weeks ago and no one has looked into it as far as I can tell. You could possibly write your own Turtle module, as a wrapper to the official one, using properties the way you mention.
Yes, I prefer the first style too.
This would not be possible: x would just be a variable, with no relation to a given turtle. At the very least, one would need to call some update() function which could look at the values of the variables in locals() and proceed from there.... But I think that this would be counter-intuitive and not a good way to teach about Python. André

Hi, On Tue, Apr 28, 2015 at 2:16 AM, Andre Roberge <andre.roberge@gmail.com> wrote:
Yes... but I would feel a bit lonely :) There were some changes for turtle in py3, and earlier many improvements were taken from xturtle module, which originated from here <http://python4kids.net/turtle.html>. Maybe it is possible to find the guys behind it... Probably the more (tested) improvements are in one place/module, the more it is possible to get it into upstream. -- Jurgis Pralgauskis tel: 8-616 77613; Don't worry, be happy and make things better ;) http://galvosukykla.lt
participants (2)
-
Andre Roberge
-
Jurgis Pralgauskis