break in a module
Chris Angelico
rosuav at gmail.com
Thu Jun 16 20:01:40 EDT 2011
On Fri, Jun 17, 2011 at 9:29 AM, Erik Max Francis <max at alcyone.com> wrote:
> Chris Angelico wrote:
>>
>> On Fri, Jun 17, 2011 at 8:07 AM, Erik Max Francis <max at alcyone.com> wrote:
>>>
>>> It's quite consistent on which control structures you can break out of --
>>> it's the looping ones.
>>
>> Plus functions.
>
> No:
>
>>>> def f():
> ... break
> ...
> File "<stdin>", line 2
> SyntaxError: 'break' outside loop
Yes:
def f():
return
print("Won't happen")
"break out of" doesn't necessarily require the break keyword per se.
You can abort a function part way, same as you can abort a loop part
way.
ChrisA
More information about the Python-list
mailing list