"Albert-Jan Roskam" <[email protected]> wrote
I'm wondering what is the most common method of input validation.
Any and all of the methods will work in different situations but its
generally best to use duck typing and try to write code that works
for any type as far as possible.
Then use exceptions to catch the ,erm, exceptions...
So you could do
try: param.readlines()
except AttributeError: # not a file like object
try param.uppercase()
except AttributeError: # not a string
And so on.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor