On Wed, Oct 24, 2012 at 10:18 AM, Morten Engvoldsen <mortene...@gmail.com> wrote: > > grams = eval(raw_input("How many grams? ")) > > Is it good practice to write code in this way.
That's equivalent to using input(). http://docs.python.org/library/functions.html#input It's not generally a good practice. Sometimes it might be desirable to use eval/exec, but there needs to be a good reason. Getting a number from a user is not a good reason. Use int(raw_input()). This might raise a ValueError, so you need to learn how to handle exceptions, as covered in the tutorial: http://docs.python.org/tutorial/errors.html#handling-exceptions _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor