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)
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 '
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
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
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
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