Noob question: Is all this typecasting normal?
Ben Finney
bignose+hates-spam at benfinney.id.au
Fri Jan 2 18:18:55 EST 2009
vk <vminch at gmail.com> writes:
> There needs to be a "user_io" or "sanitize" module in the standard
> library to take care of this stuff.
> Like:
>
> import userio
>
> logic = userio.userio()
>
> number = logic.getNumeric("blah: ") # will offer the user a "re-do" in
> case of bad input
> number = logic.forceGetNumeric("Enter your bet!: ") # even if input is
> tainted, will return some number
>
> text = logic.getText("blargh: ") # return all text
>
> text = logic.setValidText("[A-Za-z]")
> text = logic.forceGetText("blargh: ") # return some text, strips
> invalid chars
>
>
> ... but there isn't, as far as I know.
If there were, I would expect it to conform with PEP 8 (get those ugly
camelCase names outta there :-)
--
\ “The face of a child can say it all, especially the mouth part |
`\ of the face.” —Jack Handey |
_o__) |
Ben Finney
More information about the Python-list
mailing list