Input() in Python3
mwilson at the-wire.com
Mon Apr 25 12:50:50 EDT 2011
Westley Martínez wrote:
> On Fri, Apr 22, 2011 at 10:08:20AM -0400, Mel wrote:
[ ... ]
>> But sys.exit() doesn't return a string. My fave is
>> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
>> [GCC 4.4.3] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import sys
>> >>> a = int (input ('enter a number >'))
>> enter a number >sys.setrecursionlimit(1)
>> Exception RuntimeError: 'maximum recursion depth exceeded while calling a
>> Python object' in <type 'exceptions.RuntimeError'> ignored
[ ... ]
I guess sys.setrecursionlimit was meant to be called with a large number.
Calling it with a small one roadblocks the interpreter. Luckily, there can
be just enough room to call setrecursionlimit again with something
reasonable to get it all back. Not enough room for `eval
("sys.setrecursionlimit (2000)`, though.
More information about the Python-list