Re: [Edu-sig] teaching python using turtle module

2009-11-30 Thread Gregor Lingl
kirby urner schrieb: I'm glad turtle graphics intersected my thinking re extended precision decimals (Decimal type) on edu-sig just now. I've updated my tmods.py to contain a turtle rendering the plane-net of a T-mod: http://www.4dsolutions.net/ocn/python/tmod.py (runnable source) http://www.

Re: [Edu-sig] teaching python using turtle module

2009-11-30 Thread Gregor Lingl
Hello Brian, I think the most natural use of the if statement (using turtle graphics) occurs in recursive functions drawing trees, fractals and the like. This is well known from Logo, where recursion is the canonical way of doing repetitions. (But note, that Logo has tail recursion optimizaton!)

Re: Splitting a string into substrings of equal size

2009-08-17 Thread Gregor Lingl
Simon Forman schrieb: On Aug 14, 8:22 pm, candide wrote: Suppose you need to split a string into substrings of a given size (except possibly the last substring). I make the hypothesis the first slice is at the end of the string. A typical example is provided by formatting a decimal string with

Re: Splitting a string into substrings of equal size

2009-08-16 Thread Gregor Lingl
Mark Tolonen schrieb: "Gregor Lingl" wrote in message news:4a87036a$0$2292$91cee...@newsreader02.highway.telekom.at... Emile van Sebille schrieb: On 8/14/2009 5:22 PM candide said... ... What is the pythonic way to do this ? I like list comps... >>> jj = &

Re: getting the fractional part of a real?

2009-08-15 Thread Gregor Lingl
Christian Heimes schrieb: Roy Smith schrieb: What's the best way to get the fractional part of a real? The two ways I can see are r % 1 and r = int(r), but both seem a bit hokey. Is there something more straight-forward that I'm missing, like fraction(r)? import math math.modf(1.5) (0.5,

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Gregor Lingl
Emile van Sebille schrieb: On 8/14/2009 5:22 PM candide said... ... What is the pythonic way to do this ? I like list comps... >>> jj = '1234567890123456789' >>> ",".join([jj[ii:ii+3] for ii in range(0,len(jj),3)]) '123,456,789,012,345,678,9' >>> Emile Less beautiful but more correct:

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Gregor Lingl
What is the pythonic way to do this ? For my part, i reach to this rather complicated code: # -- def comaSep(z,k=3, sep=','): z=z[::-1] x=[z[k*i:k*(i+1)][::-1] for i in range(1+(len(z)-1)/k)][::-1] return sep.join(x) # Test for z in ["75096042068045", "509",

Re: Splitting a string into substrings of equal size

2009-08-15 Thread Gregor Lingl
What is the pythonic way to do this ? For my part, i reach to this rather complicated code: # -- def comaSep(z,k=3, sep=','): z=z[::-1] x=[z[k*i:k*(i+1)][::-1] for i in range(1+(len(z)-1)/k)][::-1] return sep.join(x) # Test for z in ["75096042068045", "509",

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Gregor Lingl
Mensanator schrieb: On Aug 5, 5:31 pm, Mensanator wrote: I fixed this to produce the actual image I'm looking for instead of that stupid black square. All I did was use up() & dowm() in place of penup(), pendown() and replace dot(2) with forward(1). I'll be posting a followup report later.

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Gregor Lingl
Mensanator schrieb: It didn't form 2.5 to 2.6 (at least not intentionally). But with the indroduction of the TurtleScreen class and the Screen class/object (singleton) a few of the turtle methods were also implemented as screen methods and as turtle methods declared deprecated (see docs of Python

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Gregor Lingl
Steven D'Aprano schrieb: 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

Re: Turtle Graphics are incompatible with gmpy

2009-08-05 Thread Gregor Lingl
Mensanator schrieb: I hadn't noticed this before, but the overhaul of Turtle Graphics dating back to 2.6 has been broken as far as gmpy is concerned. I hadn't noticed because I usually have tracing turned off (tracing off takes 3-4 seconds, tracing on takes 6-7 minutes). In 3.1, tracing is now

Re: Overlap in python

2009-08-04 Thread Gregor Lingl
Gregor Lingl schrieb: As my proposed solution shows this approach can be done with on board means of Python (namely the set type). This would be quite different though, if you had floating point boundaries of the intervals. ... or if the intgers involved were very big :-( Regards, Gregor

Re: Overlap in python

2009-08-04 Thread Gregor Lingl
DuaneKaufman schrieb: On Aug 4, 1:15 pm, Jay Bird wrote: ... For instance the interval module found at: http://members.cox.net/apoco/interval/ can be put to use: Given your data above: part name location a 5-9 b 7-10 c 3-6 from interval

Re: Overlap in python

2009-08-04 Thread Gregor Lingl
Jay Bird schrieb: Hi everyone, I've been trying to figure out a simple algorithm on how to combine a list of parts that have 1D locations that overlap into a non- overlapping list. For example, here would be my input: part name location a 5-9 b 7-10 c

Re: Announcing PythonTurtle

2009-08-04 Thread Gregor Lingl
cool-RR schrieb: Hi Ram, that's indeed a nice starting point for kids to doing turtle graphics, although currently it seems to implement only a very small subset of Python's turtle module's capabilities, even less than those of the old turtle module (that shipped with Python upto 2.5). ... A t

Re: Announcing PythonTurtle

2009-08-04 Thread Gregor Lingl
cool-RR schrieb: On Aug 4, 7:12 am, John Posner wrote: ... I would also venture to say a key-map ... If you're asking WHY I put it in a wxPython application, the answer is pretty much what "r" said: To make it like any other "over the counter" Windows application, making people feel more co

Re: Announcing PythonTurtle

2009-08-04 Thread Gregor Lingl
cool-RR schrieb: Hello, I wanted to announce that I have just released my little side project, PythonTurtle. Here is its website: http://pythonturtle.com Its goal is to be the lowest-threshold way to learn (or teach) Python. You can read more about it and download it on the website. Ram. Hi

ANN: Python's turtle module: collection of examples + demoViewer

2009-08-04 Thread Gregor Lingl
Hi all, A few days ago I've created a repository of turtle graphics demos/applications, that use Python's new turtle module. You can find it at at google code: http://python-turtle-demo.googlecode.com There are two versions of the collection: one for use with Python 3.1 and one for use with P