Input in Sublime Text

Asked

Viewed 877 times

4

I am using Sublime Text to study python, but it does not support input.

When running the following code with the sublime build:

velocidade = int(input("Digite a velocidade: "))

I get the following error:

Type the speed: Traceback (Most recent call last): File "/Users/matheusbaumgart/Desktop/python/others/Blank.py", line 1, in speed = int(input("Type speed: "))Eoferror: EOF when Reading a line

Someone knows a good solution to use direct input in the sublime?

1 answer

4


I suggest you try the tool Sublimerepl. With it you can create a tab to be used as interactive input for your program.

inserir a descrição da imagem aqui

Source: that answer in the SOEN

Note: I see you’re using input and then trying to convert to a int. This is not necessary. The input already reads the content as Python code, while the raw_input returns it as a simple string (i.e. input(prompt) is equivalent to eval(raw_input(prompt))). For security reasons, I suggest using raw_input whenever possible.

  • Thanks, I installed here, only what I miss is a shortcut to run the current code, as I am studying, I need to run it several times, would have some? I searched if not found. For interactive input the terminal is serving well :)

  • 1

    I don’t know any, the only alternative I can suggest is to put your code in a function and execute that function from the terminal. See the code in that question for an example (this is a standard widely used in practice in Python programs).

  • @Matheusbaumgart if by running the current code you mean running the selection or the line, see this question http://answall.com/questions/8648/howto run a-linha-actual-no-sublime-text-2-ou-ide-que-permita-execucao-da-l

Browser other questions tagged

You are not signed in. Login or sign up in order to post.