Reputation: 11
I'm starting in Python with Spyder (I just did some work on Jupyter and it was ok ...), but when typing any code in the Editor, the command lines are always shown "runfile ('C: /Users/alexandre.lustosa/ Without title1.py '), instead of the code. What should I do? Below is a very simple example of the above problem ... Thank you!
Upvotes: 1
Views: 9834
Reputation: 1065
Well, ok here we go:
The window in the bottom right corner (where the runfile-message appears) is the actual console of python. This is where you type in a command and get output back:
In [1]: print("hello")
hello
In [2]: a = 10
In [3]:
In [4]: print(a)
10
As you can see, just assigning a variable won't return any output, even though python has a=10
internaly saved. To actually get some output which is apparently your aim, you have to call a function which returns something. For example the already built in type()
function:
In [5]: type(a)
Out[5]: int
However, you have written your code in the left window, thats not a console but a python file (in your case called titulo1.py), shown by spyder. Spyder knows it's a python-file and therefore highlights the syntax.
When you now click the run icon in the top menu bar, spyder passes your file to the python console in the bottom right corner and the code in the file is then executed.
You could also manually type in the command runfile(filename) in the console. The run-symbol just saves time.
Spyder is successfully executing your code, but doesn't return anything, because a variable assignment (a=10) simply doesn't return anything.
You can activate the variable explorer of spyder, which allows you to watch all currently assigned variables:
Upvotes: 3