Turtle Graphics are incompatible with gmpy

casevh casevh at gmail.com
Wed Aug 5 09:50:17 EDT 2009


On Aug 5, 12:19 am, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> On Wed, 5 Aug 2009 03:49 pm Mensanator wrote:
>
> > In 3.1, tracing is now a screen attribute, not a turtle atribute.
> > I have no idea why
>
> >   tooter = turtle.Turtle()
> >   tooter.tracer(False)
>
> > doesn't give me an error (I thought silent errors were a bad thing).
>
> What makes it an error? Do you consider the following an error?
>
> >>> class Test:
>
> ...     pass
> ...
>
> >>> t = Test()
> >>> t.tracer = 5
>
> Perhaps you mean, it's an API change you didn't know about, and you wish to
> protest that Turtle Graphics made an incompatible API change without
> telling you?
>
> > Naturally, having tracing on caused my program to crash.
>
> It seg faulted or raised an exception?
>
> [...]
>
> > Unfortunately, that calculation of nhops is illegal if diffsq is
> > an .mpf (gmpy floating point). Otherwise, you get
>
> How does diffsq get to be a mpf? Are gmpy floats supposed to be supported?
>
> --
> Steven

The root cause of the error is that GMP, the underlying library for
gmpy, provides only the basic floating point operations. gmpy
implements a very limited exponentiation function. Python's math
library will convert an mpf to a float automatically so I think the
revised calculation for nhops should work with either any numerical
type that supports __float__.

casevh



More information about the Python-list mailing list