Noob question: Is all this typecasting normal?

John Machin sjmachin at lexicon.net
Fri Jan 2 20:06:02 EST 2009


On Jan 3, 11:16 am, vk <vmi... at gmail.com> wrote:
> > If there were, I would expect it to conform with PEP 8 (get those ugly
> > camelCase names outta there :-)
>
> haha, please forgive me.
> I'll try and think of some more creative names.
>
> atm, I've got a chem final to study for.
> I'll probably post something resembling useful code tomorrow morning.
>
> until then, int(input()) away!

Building on the earlier example (entering the amount of money for a
bet), consider the following possibilities:
10
$10
USD 10.00
USD 10,00 # many European locales
10000 # moving to the high rollers table
10,000
10.000 # European
10T # T -> thousand

dates:
1/12/35 # 1 December or 12 January? What year? 2035? Perhaps not, if
the prompt was 'Enter pensioner's date of birth -> '.

etc etc ... IOW consider not biting off more than you can chew.

Also consider that raw_input is not sufficiently frequently used in
real-world applications to warrant a data validation library to be
built on top of it.



More information about the Python-list mailing list