exit() builtin, was Re: imaplib: is this really so unwieldy?

Peter Otten __peter__ at web.de
Wed May 26 10:40:18 EDT 2021


On 26/05/2021 01:02, Cameron Simpson wrote:
> On 25May2021 15:53, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
>> On Tue, 25 May 2021 19:21:39 +0200, hw <hw at adminart.net> declaimed the
>> following:
>>> Oh ok, it seemed to be fine.  Would it be the right way to do it with
>>> sys.exit()?  Having to import another library just to end a program
>>> might not be ideal.
>>
>> 	I've never had to use sys. for exit...
>>
>> C:\Users\Wulfraed>python
>> Python ActivePython 3.8.2 (ActiveState Software Inc.) based on
>> on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> exit()
> 
> !!!!!!!!
> 
> I have learned a new thing today.
> 
> Regardless, hw didn't call it, just named it :-)

exit() is inserted into the built-ins by site.py. This means it may not 
be available:

PS D:\> py -c "exit('bye ')"
bye
PS D:\> py -S -c "exit('bye ')"
Traceback (most recent call last):
   File "<string>", line 1, in <module>
NameError: name 'exit' is not defined

I have no idea if this is of any practical relevance...



More information about the Python-list mailing list