[Edu-sig] turtle: properties instead of setters/getters ?

Jurgis Pralgauskis jurgis.pralgauskis at gmail.com
Tue Apr 28 23:57:45 CEST 2015


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 at gmail.com> wrote:

> 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 at gmail.com> wrote:
>
>> 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
>>
>
>
>
> --
> Jurgis Pralgauskis
> tel: 8-616 77613;
> Don't worry, be happy and make things better ;)
> http://galvosukykla.lt
>



-- 
Jurgis Pralgauskis
tel: 8-616 77613;
Don't worry, be happy and make things better ;)
http://galvosukykla.lt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20150429/2d85d442/attachment.html>


More information about the Edu-sig mailing list