Re: python segfault

2012-03-28 Thread Kiuhnm
thinking much -> just adding two zeros to the default limit (quick and dirty) -> segfault ==> subject: python segfault ;-) You give up too easily! Here's another way: ---> def get_steps2(pos=0, steps=0, level = 100): if steps == 0: pos = random.randint(-1,1)

Re: python segfault

2012-03-27 Thread Michael Poeltl
vial conversion to a non-recursive equivalent. > > All you need do is add a while True: to the beginning of the > function, and remove the return statement. yeah - of course 'while True' was the first, most obvious best way... ;-) but I was asked if there was a way without '

Re: python segfault

2012-03-27 Thread Dave Angel
On 03/27/2012 06:27 PM, Michael Poeltl wrote: hi, can anybody tell why this 'little stupid *thing* of code' let's python-3.2.2, 2.6.X or python 2.7.2 segfault? def get_steps2(pos=0, steps=0): ... if steps == 0: ... pos = random.randint(-1,1) ... if pos == 0: ... retur

Re: python segfault

2012-03-27 Thread Christian Heimes
Am 28.03.2012 00:27, schrieb Michael Poeltl: > hi, > > can anybody tell why this 'little stupid *thing* of code' let's python-3.2.2, > 2.6.X or python 2.7.2 segfault? The code segfaults because you have increased the recursion limit. The amount of recursions is limited by the stack size. A C pro

Re: python segfault

2012-03-27 Thread Chris Kaynor
On Tue, Mar 27, 2012 at 3:27 PM, Michael Poeltl wrote: > hi, > > can anybody tell why this 'little stupid *thing* of code' let's python-3.2.2, > 2.6.X or python 2.7.2 segfault? > >>> def get_steps2(pos=0, steps=0): > ...     if steps == 0: > ...         pos = random.randint(-1,1) > ...     if pos

python segfault

2012-03-27 Thread Michael Poeltl
hi, can anybody tell why this 'little stupid *thing* of code' let's python-3.2.2, 2.6.X or python 2.7.2 segfault? >> def get_steps2(pos=0, steps=0): ... if steps == 0: ... pos = random.randint(-1,1) ... if pos == 0: ... return steps ... steps += 2 ... pos += rando