Hi!

I'm trying to write some code that should work with both Python 2 and 3. One of the problems there is that the input() function has different meanings, I just need the raw_input() behaviour of Python 2.


My approach is to simply do this:

  try:
      # redirect input() to raw_input() like Python 3
      input = raw_input
  except NameError:
      # no raw input, probably running Python 3 already
      pass


What do you think? Any better alternatives?

Uli
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to