Which app for python?

Hi guys, I’m trying to learn python so I downloaded the Spyder but every time I wrote a code like this:

print(3 + 5)

console show it with a message like this:

runfile(‘C:/Users/Halil/Desktop/python_psyc/data_nvf.py’, wdir=‘C:/Users/Halil/Desktop/python_psyc’)
8

I can’t get rid of this runfile… thing. I try to search for a solutions on forums but I couldn’t find anything. I’m using Python 3.8.

I’m wondering which app do you use for python and do you know how can I rid of from this runfile… thing. Because it’s cause really big mess on console.

Thank you.

Hello!

I’m not sure if this will work, but try to clear the console by adding this at the start of your script(s):

import os
cls = lambda: os.system('cls') # For linux, change it to 'clear'
cls()

# Put your code after this

You can just run your scripts/programs using the console (assuming it’s on your PATH environment variable) with: python your-script-file.py.

Hope it helps :slight_smile:,

Regards and happy coding!

1 Like

Thank you for answering.
Actually I’ve already try this codes you writing but now I tried it again:

import os
cls = lambda: os.system(‘cls’) # For linux, change it to ‘clear’
cls()

print(3 + 5)

But I got a same result:

runfile(‘C:/Users/Halil/Desktop/python_psyc/data_nvf.py’, wdir=‘C:/Users/Halil/Desktop/python_psyc’)
8

Sorry I didn’t get this can you explain :
“assuming it’s on your PATH environment variable”

Screenshot:

It seems that there’s no way to remove it :frowning: as explained here: How do I disable the 'runfile (...)' expression when running a python script from Spyder? · Issue #2254 · spyder-ide/spyder · GitHub.

You could write something like this though:

print('-----PROGRAM START-----')
print('\n\n\n')
print(5 + 3)

This would print the string and 4 new lines before your output.

The PATH variable is a configuration that tells the OS where to find certain programs. Just to keep it DRY, you can read more about it here.

Search online on how to set it up on Windows :slight_smile:, it’s not hard to configure.

1 Like

Through this codes I’m getting the runfile message for just once. Now my console is look more clear, thank you.

1 Like