[Tutor] Is my style OK in this elementary student exercise?

Tim Peters tim.peters at gmail.com
Sun Jul 5 22:12:49 CEST 2009


[Angus Rogers, suffering eval-angst]
> ...
> On the other hand, so long as I AM only executing the function
> myself, I am no more at risk than I already am every single time
> I type a command into a Python interpreter, of any description.
> (A somewhat Existentialist thought, perhaps!  Virtual suicide
> is always a possibility.) >->
>
> Does that seem reasonable?  You've made me clearly aware of a
> risk that I was only vaguely aware of before (I ruminated only
> briefly as to whether any harm might come from entering general
> Python expressions, but my main feeling about this facility was
> that it would probably be useful - in some "future exercise"),
> but isn't there a role for functions that one can use oneself,
> but never ever distribute to the "general public"?

Certainly!  I use eval() and input() all the time in my private code
(but never in released code), and you're never going to screw yourself
"by accident" doing so.  Especially if you have an interest in writing
mathematical code, it's a tremendous convenience for prompted input to
support arbitrary computation.


> If so, are the precautions I have suggested above sufficient?

In private code, any precautions are probably just a waste of time.
You really don't, for example, need to remind /yourself/ not to enter
a convoluted expression that emails your credit card info to a hacker
site in Nigeria.  Or if you do need to remind yourself not to do
things like that, you probably shouldn't be using a computer to begin
with ;-)


More information about the Tutor mailing list