Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6015 > unrolled thread

Strange behaviour of input() function (Python 3.2)

Started bysunrrrise <sunrrrise@gmail.com>
First post2011-05-22 15:43 -0700
Last post2011-05-23 08:49 +1000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Strange behaviour of input() function (Python 3.2) sunrrrise <sunrrrise@gmail.com> - 2011-05-22 15:43 -0700
    Re: Strange behaviour of input() function (Python 3.2) Chris Angelico <rosuav@gmail.com> - 2011-05-23 08:49 +1000

#6015 — Strange behaviour of input() function (Python 3.2)

Fromsunrrrise <sunrrrise@gmail.com>
Date2011-05-22 15:43 -0700
SubjectStrange behaviour of input() function (Python 3.2)
Message-ID<1dc07caf-c938-42d0-8ba4-4fc9564af84e@glegroupsg2000goo.googlegroups.com>
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

[toc] | [next] | [standalone]


#6018

FromChris Angelico <rosuav@gmail.com>
Date2011-05-23 08:49 +1000
Message-ID<mailman.1936.1306104560.9059.python-list@python.org>
In reply to#6015
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web