python newbie
broebel
computer.problemen at skynet.be
Sat Jan 10 10:30:51 EST 2004
Just like you don't speak dutch, I don't write python (that's a good reason
to learn, isn't it) so I'm not trying out your proposal to see wheather it
works or not.
I kept it aside to check as soon as I understand more of the language. So
thanks any way.
btw is there a special reason why someone should speak dutch to programm in
python.?
"djw" <donald.welch.nospam at hp.com> schreef in bericht
news:3fff1245 at usenet01.boi.hp.com...
> Joe Francia wrote:
>
> > d wrote:
> >> Worked fine for me on Linux... made two suggested changes: 1) use
> >> raw_input(), not input(), 2) check user input for errors. Sorry, I
don't
> >> know how to say "Enter a number between 0 and 500" in whatever language
> >> this is in (German?)
> >>
> >
> > You're a Python user and you don't recognize Dutch?!?! For shame... ;>)
>
> Well, I was only off by one country - not too bad for someone who took 4
> years of high school Spanish and can hardly speak a word of it.
>
> I was looking at the code that I proposed to the OP, and wondered if this
> wasn't better:
>
> #!/usr/bin/env python
> while 1:
> bedrag = raw_input ( 'Geef bedrag tussen 0 en 500 eurocent: ' )
> try:
> bedrag = int( bedrag )
> if bedrag < 0 or bedrag > 500:
> raise ValueError
> except ValueError:
> print "Enter a number between 0 and 500" # In DUTCH, of course!
> else:
> break
>
> # ... etc.
>
>
> Is this good style, that is, to put multiple items inside a single try:
> except: else: block? Seems more compact and tidy than my first try.
>
> -d
>
>
>
More information about the Python-list
mailing list