On Fri, Sep 23, 2016 at 7:33 AM, אלעזר <elaz...@gmail.com> wrote:
> On Fri, Sep 23, 2016 at 12:18 AM Chris Angelico <ros...@gmail.com> wrote:
>>
>> # Recursion in functions
>> def spam():
>>     return spam()
>
>
> I just note that it *is* surprising, for most users, that you can't be sure
> that this is a recursion, yet. So it if you want a trusted-upon recursion
> you should write
>
> # spam:
> def spam():
>     def spam():
>         return spam()
>     return spam()
>
>

Only surprising for people who want it _guaranteed_. It's the exact
same problem as this:

def helper(x):
    ...

def spaminate(x, y):
    helper(x)
    helper(y)

How do you know that a replacement helper hasn't been injected? You
don't... but you trust that people aren't normally going to do that,
and if they do, they're taking responsibility (maybe they're mocking
helper for testing).

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to