Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78071
| References | <mailman.14114.1411063879.18130.python-list@python.org> <541bc310$0$29975$c3e8da3$5496439d@news.astraweb.com> <mailman.14135.1411109125.18130.python-list@python.org> <541c0dc9$0$29992$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| Date | 2014-09-19 21:36 +1000 |
| Subject | Re: program to generate data helpful in finding duplicate large files |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14142.1411127046.18130.python-list@python.org> (permalink) |
On Fri, Sep 19, 2014 at 9:04 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
>> Hmm, you sure exit won't work?
>
> In the interactive interpreter, exit is bound to a special helper object:
>
> py> exit
> Use exit() or Ctrl-D (i.e. EOF) to exit
>
> Otherwise, you'll get NameError.
It's not the interactive interpreter alone. I tried it in a script
before posting.
Python 2.7.3 on Linux, 2.6.8 on Linux, 3.5.0ish Linux, 2.7.8 Windows,
2.6.5 Windows, 3.3.0 Windows, and 3.4.0 Windows, all work perfectly,
with (AFAIK) default settings. The only one that I tried that doesn't
is:
C:\>type canIexit.py
import sys
print(sys.version)
print(exit)
print(type(exit))
exit(1)
C:\>python canIexit.py
2.4.5 (#1, Jul 22 2011, 02:01:04)
[GCC 4.1.1]
Use Ctrl-Z plus Return to exit.
<type 'str'>
Traceback (most recent call last):
File "canIexit.py", line 5, in ?
exit(1)
TypeError: 'str' object is not callable
I've no idea how far back to go before it comes up with a NameError.
However, this is provided (as is made clear by the type lines) by
site.py, and so can be disabled. But with default settings, it is
possible to use exit(1) to set your return value.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
program to generate data helpful in finding duplicate large files David Alban <extasia@extasia.org> - 2014-09-18 11:11 -0700
Re: program to generate data helpful in finding duplicate large files Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-19 15:45 +1000
Re: program to generate data helpful in finding duplicate large files Chris Angelico <rosuav@gmail.com> - 2014-09-19 16:45 +1000
Re: program to generate data helpful in finding duplicate large files Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-19 21:04 +1000
Re: program to generate data helpful in finding duplicate large files Chris Angelico <rosuav@gmail.com> - 2014-09-19 21:36 +1000
Re: program to generate data helpful in finding duplicate large files Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-20 09:33 +1000
Re: program to generate data helpful in finding duplicate large files Chris Angelico <rosuav@gmail.com> - 2014-09-20 14:47 +1000
Re: program to generate data helpful in finding duplicate large files Ian Kelly <ian.g.kelly@gmail.com> - 2014-09-19 11:20 -0600
Re: program to generate data helpful in finding duplicate large files Chris Angelico <rosuav@gmail.com> - 2014-09-20 03:36 +1000
csiph-web