Strange behaviour of input() function (Python 3.2)

Discussion in 'Python' started by sunrrrise, May 22, 2011.

  1. sunrrrise

    sunrrrise Guest

    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
    sunrrrise, May 22, 2011
    #1
    1. Advertising

  2. On Mon, May 23, 2011 at 8:43 AM, sunrrrise <> 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, May 22, 2011
    #2
    1. Advertising

  3. Re: Re: Strange behaviour of input() function (Python 3.2)

    On Mon, May 23, 2011 at 8:59 AM, sunrrrise <> 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
    Chris Angelico, May 23, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nikk & Jak Anderson

    GZIP output and input strange behaviour

    Nikk & Jak Anderson, Apr 26, 2004, in forum: Java
    Replies:
    2
    Views:
    1,137
    Roedy Green
    Apr 26, 2004
  2. muser
    Replies:
    9
    Views:
    319
    Rolf Magnus
    Oct 14, 2003
  3. Replies:
    23
    Views:
    709
    Dave Thompson
    Nov 20, 2006
  4. Paulo da Silva
    Replies:
    8
    Views:
    361
  5. Rahul!!

    strange behaviour w.r.t get function

    Rahul!!, Mar 30, 2011, in forum: Perl Misc
    Replies:
    2
    Views:
    105
    Willem
    Mar 30, 2011
Loading...

Share This Page