[Tutor] dangers of input() (original) (raw)
Alan Gauld alan.gauld at blueyonder.co.uk
Tue Jul 20 23:57:59 CEST 2004
- Previous message: [Tutor] dangers of input()
- Next message: [Tutor] Re: Program Questions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I was thinking of using input() instead of rawinput in my Frac.py (posted yesterday). This would enable the user to enter things such as "4**-3". Am I correct in assuming that this would be impossible to do without using input()?
No, you could use eval() instead. eval() has the advantage of allowing you to sanity check the string before executing it.
input allows a user to type
import os; os.system('del .')
If so, I may go ahead with input()--I'm the only user, after all.
If you will always be the sole user input is fine, I use it all the time for my own use, but be aware that own-use can often become shared use...
Alan G.
- Previous message: [Tutor] dangers of input()
- Next message: [Tutor] Re: Program Questions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]