Loop exception catching

Aldo Cortesi aldo at nullcube.com
Tue Jan 24 23:37:38 EST 2006

Thus spake Ivan Shevanski (darkpaladin79 at gmail.com):

> Thanks, that seems to work fine.  But about your other comment. . .
> >Well, leaving aside the merits of using "input" (which should be avoided at
> >all costs)
> What do you mean?

Well, the problem with "input" is that it allows the user to supply an
arbitrary Python expression, which will then be executed. Among other things,
this means that your pet cat could make your script exit due to an uncaught
exception by simply walking accross your keyboard. If your cat is sufficiently
clever, it could also empty your bank account, email your entire porn
collection to your mother, and then erase your hard drive.

In short, using "input" means that your programme could potentially behave in
some arbitrary way that is simply impossible to predict, depending on what is
supplied by the user. Just use "raw_input" instead - it just takes input from a
user without evaluating it as a Python expression, and will bring order and
predictability to whatever it is you want to do.



Aldo Cortesi
aldo at nullcube.com
Mob: 0419 492 863

More information about the Python-list mailing list