I have found that running a program in IDLE is slower then running it by right clicking and openwith Python. Also, that second way let's me run multiple instances. The following code works fine in IDLE..
def main():
var = 123
# Writes
fo = open('test.py', 'w')
fo.write('num = ')
fo.write(str(var))
fo.close()
However it crashes when I try to run it in the openwith way. No error that I can see.
Can someone tell what is happening or maybe how to write a file while using the openwith way?
You should choose another IDE. Python.org includes Idle with python, but it is a poor IDE and really shouldn't be used.
Although choice of an IDE is personal, VSCode is highly recommended, easy to install and learn, and offers many extensions.
You can install and try it out using this installation procedure:
https://python-forum.io/Thread-VS-Code-f...ght=VSCode
as an FYI, a better way to open and read files is with the context manager 'with' statement:
def main():
var = 123
# Writes
with open('test.py', 'w') as fo:
fo.write('num = {}'.format(var))
No close necessary
this can be simplified further:
def main():
# Writes
with open('test.py', 'w') as fo:
fo.write('num = {}'.format('123'))
I use PyCharm it is pricey but one of the best I have tried.
I have used Visual Code and Notepad++ both are good for a quick edit.
I use Anaconda3 that has the Jupyter editor which I find very good for learning and testing Python code.
Quote:I use PyCharm it is pricey but one of the best I have tried.
PyCharm has a free community edition which is fine if not in commercial setting.
I used PyCharm for a long time (years), but found VSCode more suitable for my own work.
As I stated, it's personal.
I agree. I am 72 years old and started programming with assembly. You use what makes you happy.