pos() not working as expected?
Closed this issue · 5 comments
caternuson commented
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)
>>>
ladyada commented
oof dunno - i always printed it? maybe repr is different than what is called in print()?
caternuson commented
yep. appears so.
>>> class Foo():
... def __repr__(self):
... return "__repr__"
... def __str__(self):
... return "__str__"
...
>>> f = Foo()
>>> f
__repr__
>>> print(f)
__str__
>>>
ladyada commented
i think repr would be a tuple right?
caternuson commented
i think so, but in string format:
https://docs.python.org/3.7/reference/datamodel.html#object.__repr__
caternuson commented
Fixed with #15