Re: consistent input() for Python 2 and 3

2012-08-02 Thread Jason Swails
On Thu, Aug 2, 2012 at 5:49 AM, Ulrich Eckhardt < ulrich.eckha...@dominolaser.com> wrote: > 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 P

Re: consistent input() for Python 2 and 3

2012-08-02 Thread Philipp Hagemeister
On 08/02/2012 11:49 AM, Ulrich Eckhardt wrote: > 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? That's the generic so

consistent input() for Python 2 and 3

2012-08-02 Thread Ulrich Eckhardt
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() lik