[Tutor] renaming input works intermittently
eryksun
eryksun at gmail.com
Fri Jul 12 03:07:27 CEST 2013
On Thu, Jul 11, 2013 at 9:01 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>> try:
>> if int(sys.version[0]) < 3:
>> input = raw_input
>> numbers_str = original = input('Enter a positive'
>> 'integer, space separated if desired.') # error occurs here
>>
>> Oddly, the error only occurs in Python 3.3 - the above works in Python 2.7
>
> The rules for local variables are rather more complicated in Python 2 and it
> may be that you're somehow slipping through the cracks.
In 2.x the if statement executes, so the local variable "input" gets assigned.
More information about the Tutor
mailing list