Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Strange behaviour of input() function (Python 3.2) (http://www.velocityreviews.com/forums/t748792-strange-behaviour-of-input-function-python-3-2-a.html)

sunrrrise 05-22-2011 10:43 PM

Strange behaviour of input() function (Python 3.2)
 
Hello,
this is my first post. I'm trying to learn Python language which I find great, but I have a big problem with its editors/IDEs.

I have tested IDLE (which installed with Python3 from ActiveState), Notepad++ and finally Komodo EDIT. I don't like IDLE GUI, but Notepad++ and Komodo EDIT looks nice for me.

Unfortunatelly there is something wrong with input() command when I'm using Komodo or Notepad. For example this code:

a = input("Wprowadz zmienna a: ")
b = input("Wprowadz zmienna b: ")
print("a to: ", a)
print("b to: ", b)
print(int(a) + int(b))

works well in IDLE, but when I'm switching to Notepad/Komodo I'm getting something like this:

Wprowadz zmienna a: 3
Wprowadz zmienna b: 2
a to: 3
b to: Wprowadz zmienna b: 2
Traceback (most recent call last):
File "c:\users\sunrrrise\Desktop\test.py", line 9, in <module>
print(int(a) + int(b))
ValueError: invalid literal for int() with base 10: 'Wprowadz zmienna b: 2'

I don't know what is going on. Any ideas or, better, solutions?

My OS: Windows 7 64bit, ActiveState Python 3.2, Notepad++ 5.9, Komodo Edit 6.1, coding: UTF-8

Regards,
sunrrrise

Chris Angelico 05-22-2011 10:49 PM

Re: Strange behaviour of input() function (Python 3.2)
 
On Mon, May 23, 2011 at 8:43 AM, sunrrrise <sunrrrise@gmail.com> wrote:
> Hello,
> this is my first post. I'm trying to learn Python language which I find great, but I have a big problem with its editors/IDEs.


Welcome!

> b to: *Wprowadz zmienna b: 2


This looks wrong. Are you copying and pasting several lines, or simply
pressing the 2 key followed by Enter?

It's showing a lengthy string in the variable 'b', which - quite
correctly - cannot be cast to int.

Chris Angelico

Chris Angelico 05-22-2011 11:21 PM

Re: Re: Strange behaviour of input() function (Python 3.2)
 
On Mon, May 23, 2011 at 8:59 AM, sunrrrise <sunrrrise@gmail.com> wrote:
> Thank you for quick response!
>
> English is not my native language so I'm going to keep my explanations simple.


No problem, your English is far better than my Polish. (I used Google
Translate to figure out what "Wprowadz zmienna" means.)

I tried copying and pasting your exact code, even down to using
Notepad, but it worked fine. The interpreter I used was a
freshly-downloaded Python 3.2, listing itself as r32:88445 dated Feb
20 2011, 21:29:03.

This may be a really specific bug. Can you email me the actual Python
file you're having problems with, please? Off-list, as this list
doesn't like attachments. I'll try running it on my system and see if
it's any different.

Chris Angelico


All times are GMT. The time now is 08:07 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.