Search code examples
pythonpycharm

Naming a new file in PyCharm


I just started learning python. Up until now, I primarly worked with jupyter notebooks, but now wanted to try out some IDEs. So I tried out PyCharm.

So I started creating some files in a project and started trying out the commands and stuff and there is one thing which just drives me crazy, cause I can not seem to find an answer.

Everytime I create a new python file and name it something like "simple_message", it just saves as a normal file and I can't run any code in it. As soon as I remove the underscore, the file convention changes to an actual python file and I can run the code written in it. So I thought it might be the underscore that makes trouble, so I tried creating other files with underscores but all of them worked. Can someone enlighten me, why does the file name "simple_message" not work as a python file?

Thank you!

From this To this


Solution

  • Currently PyCharm context menu lets you choose the file type to create. If you choose "file" you MUST provide the extension .py If You choose "Python File" pycharm handles the extension for You.

    Right click on the pycharm projects tab