error handling in user input: is this natural or just laborious
bruno de chez modulix en face
bruno at modulix.org
Sat Oct 7 15:10:08 CEST 2006
sam a écrit :
> i'm still in the early stages, and am trying to code something simple
> and interactive to get the percentages of the portfolio in the five
> different investment categories. i thought i'd get in with the error
> handling early so if someone types in something wrong (like a word), or
> the numbers don't add up to 100%, the error would be caught immediately
> and the user sent back to the start of the loop.
You may want to have a look at the formencode package. While mostly
used in web apps, it's perfectly usable for all kind of
python<->outside world data conversion/validation.
More information about the Python-list