exiting a while loop

Terry Reedy tjreedy at udel.edu
Fri May 22 18:19:10 EDT 2020


On 5/22/2020 12:31 PM, Grant Edwards wrote:
> On 2020-05-22, Peter Otten <__peter__ at web.de> wrote:
> 
>> If you want to terminate the script you can use exit. However exit
>> is a function, and you have to call it
>>
>> exit()
> 
> <pedantic>
> 
> Actually it's an instance of _sitebuiltins.Quitter not a function.

Which means that it is not part of the language and is not guaranteed to 
exist and will not if the local site module does not inject it.  quit() 
and exit() are only meant for interactive use at the >>> prompt as a 
cross-platform alternative to ^D or ^Z<enter> on non-Windows or Windows. 
They should not be used in programs unless explicitly defined or 
imported.  The reason both exist, violating the 'one obvious rule' is 
because both are (were) used used in various other REPLs and interactive 
text programs.


-- 
Terry Jan Reedy



More information about the Python-list mailing list