0

My system is debian7.8+python3.4.1 .
It is found that to copy lines from gedit into python console result in more redundant characters ,why?

I copy it into python console.

prod=1
for i in range(1,11):
    prod=prod*i


print(prod)

The lines turn into the following:

prod=1
for i in range(1,11):
    prod=prod*i


print(prod)>>> ... ... >>> >>>

I have never input the characters >>> ... ... >>> >>> in my gedit.

enter image description here

showkey
  • 482
  • 42
  • 140
  • 295

2 Answers2

0

I assume those are control characters (eg. end of line character EOF etc) that are not visible in the text editor, yet still can be copied. Are you using "select all" short-cut like ctrl+a? Try selecting the text with mouse or shift+arrow-keys and end your selection exactly after the last character of your text.

Nandor Poka
  • 281
  • 1
  • 10
0

Those are interactive feedback prompts from the console, which only arrive after you paste. If you type instead of paste, you'll see where those snippets really belong.

$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> prod=1
>>> for i in range(1,11):
...     prod=prod*i
... 
>>> 
>>> print(prod)
3628800

(I boldfaced your input; maybe change fonts if it's not obvious.)

This is not specific to Python, Debian, or Gedit (though perhaps the GUI could pause for 1/100 sec at every newline when you paste a string with newlines in it, if it's not too long, in order to give the CLI time to keep up).

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • Tangentially, see also http://stackoverflow.com/questions/2501208/copying-and-pasting-code-into-the-python-interpreter – tripleee Mar 04 '15 at 12:00