On Fri, Mar 12, 2010 at 8:30 PM, Andre Engels <[email protected]> wrote:

> On Sat, Mar 13, 2010 at 3:11 AM, Ray Parrish <[email protected]> wrote:
> > Andre Engels wrote:
> >>
> >> On 3/12/10, yd <[email protected]> wrote:
> >>>  else:
> >>>    raise Exception('{0}, is not a valid choice'.format(choice))
> >>>
> >>
> >> This will cause the program to stop-with-error if something wrong is
> >> entered. I think that's quite rude. I would change this to:
> >>  else:
> >>    print('{0}, is not a valid choice'.format(choice))
> >>
> >
> > Here's what I get from that, could you please explain why?
>
> You're probably using Python 2.4 or 2.5; the .format method has been
> introduced in Python 2.6, and is considered the 'standard' way of
> working in Python 3. For older Python versions, this should read
>
> print('%s, is not a valid choice'%(choice))
>
> Also you don't have to use parenthesis around single items, and also print
is not usually used as a function either.
So really for older versions the convention would be
print "%s, is not a valid choice" % choice

-Luke
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to