PAGE2GO2 HOME | INTERNET NEWS

LeighExchange - Free Advertising Network Stock Research at Internet Speed Need Money Easy and Quick?

Re: exit to interpreter?

 List
Subject: Re: exit to interpreter?
Poster: belindathombthom@cs.hmc.edu
Date: Fri, 23 Mar 2007 17:04:58 -0700
Related Postings: 1 2 3 4 5
Thanks to all. I had suspected this was the best way to go, but as I'm fairly new to Python, it seemed worth a check.

--b

On Mar 23, 2007, at 12:48 PM, kyosohma@gmail.com wrote:


> On Mar 23, 1:20 pm, belinda thom wrote:
>> On Mar 23, 2007, at 11:04 AM, kyoso...@gmail.com wrote:
>>
>>
>>
>>> On Mar 23, 12:52 pm, belinda thom wrote:
>>>> Hi,
>>
>>>> I'm writing a function that polls the user for keyboard input,
>>>> looping until it has determined that the user has entered a valid
>>>> string of characters, in which case it returns that string so it
>>>> can
>>>> be processed up the call stack. My problem is this. I'd also
>>>> like it
>>>> to handle a special string (e.g. 'quit'), in which case control
>>>> should return to the Python command line as opposed to returning
>>>> the
>>>> string up the call stack.
>>
>>>> sys.exit seemed like a good choice, but it exits the python
>>>> interpreter.
>>
>>>> I could use an exception for this purpose, but was wondering if
>>>> there's a better way?
>>
>>>> --b
>>
>>> If you're using a function, wouldn't using the keyword "return"
>>> work?
>>
>>> Mike
>>
>> No, because that just returns to the caller, which is not the Python
>> interpreter.
>
> Sorry...I didn't realize you were calling from another function or
> functions. Duh. I agree with the other writer. Use a custom exception.
>
> --
> http://mail.python.org/mailman/listinfo/python-list

 

Page2Go2.com is not responsible for content of this message.