[Tutor] How to exit this loop in the interpreter
Gergely Lőrincz
alkopop79 at gmail.com
Thu May 3 18:44:22 CEST 2012
I say old bean, did not get an answer and wasn't sure if it went through.
Sorry me for asking help with python in a python mailing list!
On 3 May 2012 17:30, Mark Lawrence <breamoreboy at yahoo.co.uk> wrote:
> On 03/05/2012 16:52, Gergely Lőrincz wrote:
>
>> Dear folks,
>>
>> I've been struggling to set up python on snow leopard, mac os x. Stupidly
>> I
>> downloaded and installed python 3.2 and since then the 'python' command in
>> the terminal yields 'no command found'. In addition when opening the
>> terminal I get this error message on the top of the window:
>> http://pastebin.com/QS3gpkjK
>>
>> For some reason the installation littered my Android SDK folder with
>> main.py and other kind of python files. Don't ask me why, it's beyond me.
>> I
>> removed the offending files manually and deleted the python 3.2.2 folder
>> form /Library/Frameworks/python.**framework/versions folder. After
>> rebooting
>> the terminal still complains about those files. I wonder how can I fix it?
>> I would love to learn to use python! Your help would be appreciated!
>>
>> On 3 May 2012 15:22, Simon Yan<simonyan at fedoraproject.org**> wrote:
>>
>>
>>>
>>> On Thu, May 3, 2012 at 9:57 PM,<spawgi at gmail.com> wrote:
>>>
>>> Hello all,
>>>>
>>>> I have encountered the following scenario.
>>>> Here is the code - on IDLE on Windows XP.
>>>>
>>>> *>>> while True:
>>>>
>>>> try:
>>>> number = raw_input("enter number - ")
>>>> print number * number
>>>> except ValueError:
>>>> print "invalid number"
>>>> except:
>>>> print "unspecified exception"
>>>> else:
>>>> print "other conditions"
>>>>
>>>>
>>>> enter number - 3
>>>> unspecified exception
>>>> *
>>>> What I noticed is that no matter, what input I give, I cannot exit this
>>>> loop. I have tried control-C, control-D etc. all the keys. So how can I
>>>> exit from this loop?
>>>>
>>>>
>>> If you simply want to stop after an exception was caught, you can insert
>>> "break" after each print line. Like below:
>>> >>> while True:
>>> try:
>>> number = raw_input("enter number - ")
>>> print number * number
>>> except ValueError:
>>> print "invalid number"
>>> break
>>> except:
>>> print "unspecified exception"
>>> break
>>> else:
>>> print "other conditions"
>>> break
>>>
>>>
>>>
>>>> Thanks and Regards,
>>>> Sumod
>>>>
>>>> --
>>>> http://spawgi.wordpress.com
>>>> We can do it and do it better.
>>>>
>>>> ______________________________**_________________
>>>> Tutor maillist - Tutor at python.org
>>>> To unsubscribe or change subscription options:
>>>> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>>>>
>>>>
>>>>
>>>
>>> --
>>> Regards,
>>> YeeYaa (Simon Yan)
>>>
>>> http://simonyan.fedorapeople.**org/ <http://simonyan.fedorapeople.org/>
>>>
>>> ______________________________**_________________
>>> Tutor maillist - Tutor at python.org
>>> To unsubscribe or change subscription options:
>>> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>>>
>>>
>>>
>>
>> ______________________________**_________________
>> Tutor maillist - Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>>
>
> I say old chap, it's simply not cricket to hijack a thread, particularly
> when you've already asked your question some 4 hours and 38 minutes earlier.
>
> --
> Cheers.
>
> Mark Lawrence.
>
>
> ______________________________**_________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
--
Greg Lorincz
www.greglorincz.com +447824817676
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120503/f4e02b33/attachment-0001.html>
More information about the Tutor
mailing list