adafruit/Adafruit_CircuitPython_turtle

pos() not working as expected?

Closed this issue · 5 comments

Maybe I'm just not using it as intended?

Adafruit CircuitPython 4.1.0 on 2019-08-02; Adafruit PyPortal with samd51j20
>>> import board
>>> from adafruit_turtle import turtle
>>> turtle = turtle(board.DISPLAY)
>>> turtle.pos()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lib/adafruit_turtle.py", line 133, in __repr__
TypeError: can't convert Vec2D to float
>>> 

Other overrides work OK. Ex:

>>> turtle.pos()[0]
0
>>> turtle.pos()[1]
0
>>> print(turtle.pos())
(0, 0)
>>> 

oof dunno - i always printed it? maybe repr is different than what is called in print()?

yep. appears so.

>>> class Foo():
...   def __repr__(self):
...     return "__repr__"
...   def __str__(self):
...     return "__str__"
... 
>>> f = Foo()
>>> f
__repr__
>>> print(f)
__str__
>>> 

i think repr would be a tuple right?

Fixed with #15