On 14/12/2022 13:49, Stefan Ram wrote:
I also found an example similar to what was discussed here
in pypy's library file "...\Lib\_tkinter\__init__.py":
|def _flatten(item):
|def _flatten1(output, item, depth):
|if depth > 1000:
|raise ValueError("nesting too deep i
On 13/12/2022 15:46, Michael F. Stemper wrote:
It's easy enough -- in fact necessary -- to handle the bottom
level of a function differently than the levels above it. What
about the case where you want to handle something differently
in the top level than in lower levels? Is there any way to tell
On 13/12/2022 09.03, Stefan Ram wrote:
"Michael F. Stemper" writes:
def fred(cf,toplevel=True):
x = cf[0]
if len(cf)>1:
if toplevel:
return x + fred(cf[1:],False)
else:
return "(" + x + fred(cf[1:],False) + ")"
else:
if toplevel:
return x
else:
On Wed, 14 Dec 2022 at 05:01, Mats Wichmann wrote:
>
> On 12/13/22 10:36, Chris Angelico wrote:
> > On Wed, 14 Dec 2022 at 03:35, Michael F. Stemper
> > wrote:
> >>
> >> It's easy enough -- in fact necessary -- to handle the bottom
> >> level of a function differently than the levels above it. Wh
On 12/13/22 10:36, Chris Angelico wrote:
On Wed, 14 Dec 2022 at 03:35, Michael F. Stemper
wrote:
It's easy enough -- in fact necessary -- to handle the bottom
level of a function differently than the levels above it. What
about the case where you want to handle something differently
in the top
On Wed, 14 Dec 2022 at 03:35, Michael F. Stemper
wrote:
>
> It's easy enough -- in fact necessary -- to handle the bottom
> level of a function differently than the levels above it. What
> about the case where you want to handle something differently
> in the top level than in lower levels? Is the
: Tuesday, December 13, 2022 10:25 AM
To: python-list@python.org
Subject: Re: Top level of a recursive function
Supersedes:
r...@zedat.fu-berlin.de (Stefan Ram) writes:
>def rest( s ):
>return "(" + s[ 0 ] +( rest( s[1:] ) if len( s )> 1 else '' )+ ')'
&