Re: [Tutor] break and exit

2014-11-21 Thread Peter Otten
James Rieve wrote: > I accidently used 'exit' in a loop where I meant to use 'break' and, in > that case, the program seemed to work as expected but in some cases 'exit' > seems to behave differently from 'break'. For example, in this code > snippet using 'exit' or 'break' produces the same result

Re: [Tutor] Empty GraphicsWindow

2014-11-21 Thread Alan Gauld
On 21/11/14 03:00, niyanax...@gmail.com wrote: I need help figuring why my GraphicsWindow empty, I cannot figure out why it is empty. Here is my code : # Import graphics from module from graphics import GraphicsWindow Since 'graphics' is not a standard part of Python can you tell us where you

Re: [Tutor] break and exit

2014-11-21 Thread Alan Gauld
On 21/11/14 04:10, James Rieve wrote: I accidently used 'exit' in a loop where I meant to use 'break' and, in that case, the program seemed to work as expected but in some cases 'exit' seems to behave differently from 'break'. For example, in this code snippet using 'exit' or 'break' produces the

Re: [Tutor] Dividing a float derived from a string

2014-11-21 Thread Stephanie Morrow
Alan, I am getting a syntax error when I print the following: input = raw_input("Insert a number: ") try: print float(input) * 12 except: TypeError, ValueError: print False The "try" is coming up as red. Any idea why? On Fri, Nov 21, 2014 at 12:23 AM, Alan Gauld wrote: > On 20/11/14

Re: [Tutor] Dividing a float derived from a string

2014-11-21 Thread Stephanie Morrow
This one worked! Thank you very much! :D On Fri, Nov 21, 2014 at 3:14 AM, Adam Jensen wrote: > On Thu, 20 Nov 2014 21:20:27 + > Stephanie Morrow wrote: > > > Hi there, > > > > I have been posed with the following challenge: > > > > "Create a script that will ask for a number. Check if thei

Re: [Tutor] Dividing a float derived from a string

2014-11-21 Thread Alan Gauld
On 21/11/14 13:19, Stephanie Morrow wrote: try: print float(input) * 12 except: TypeError, ValueError: print False The "try" is coming up as red. Any idea why? Sorry, I left the colon in after the else. I think that's what's confusing it... It should read: except TypeError, ValueEr

Re: [Tutor] Dividing a float derived from a string

2014-11-21 Thread Peter Otten
Alan Gauld wrote: > But that's considered bad practice, it's better to put the > valid errors only in the except line like this: > > try: > print float(input)*12 > except TypeError, ValueError: > print False Careful, you need parens around the tuple of errors, otherwise this catches o

[Tutor] urllib confusion

2014-11-21 Thread Clayton Kirkwood
Hi all. Got a general problem with url work. I've struggled through a lot of code which uses urllib.[parse,request]* and urllib2. First q: I read someplace in urllib documentation which makes it sound like either urllib or urllib2 modules are being deprecated in 3.5. Don't know if it's only par

Re: [Tutor] Dividing a float derived from a string

2014-11-21 Thread Adam Jensen
> -Original Message- > From: Tutor [mailto:tutor-bounces+hanzer=riseup@python.org] On > Behalf Of Alan Gauld > Sent: Thursday, November 20, 2014 7:24 PM > But that's considered bad practice, it's better to put the valid errors only in > the except line like this: > > try: > print

Re: [Tutor] urllib confusion

2014-11-21 Thread Joel Goldstick
On Fri, Nov 21, 2014 at 4:37 PM, Clayton Kirkwood wrote: > Hi all. > > > > Got a general problem with url work. I’ve struggled through a lot of code > which uses urllib.[parse,request]* and urllib2. First q: I read someplace in > urllib documentation which makes it sound like either urllib or urll

Re: [Tutor] urllib confusion

2014-11-21 Thread Alan Gauld
On 21/11/14 21:37, Clayton Kirkwood wrote: urllib or urllib2 modules are being deprecated in 3.5. Don’t know if it’s only part or whole. urlib2 doesn't exist in Python3 there is only the urllib package. As to urllib being deprecated, thats the first I've heard of it but it may be the case - I

Re: [Tutor] urllib confusion

2014-11-21 Thread Clayton Kirkwood
>-Original Message- >From: Joel Goldstick [mailto:joel.goldst...@gmail.com] >Sent: Friday, November 21, 2014 2:39 PM >To: Clayton Kirkwood >Cc: tutor@python.org >Subject: Re: [Tutor] urllib confusion > >On Fri, Nov 21, 2014 at 4:37 PM, Clayton Kirkwood >wrote: >> Hi all. >> >> >> >> Got