I am new to Pycharm and Python?
I am new to Pycharm and wondering about filetypes. When creating a new file it asks you to choose a filetype such as text or Python.py etc. I usually choose text, I dont know why, the coding seems to work when I run it.
So, my question is: When should I do my coding within a text file, and when with Python.py file? How do they differ? Are there any other filetypes from the list I should consider?
So, my question is: When should I do my coding within a text file, and when with Python.py file? How do they differ? Are there any other filetypes from the list I should consider?
Please sign in to leave a comment.
% cat hello.txt
print "hello world"
% python hello.txt
hello world
But in an IDE or text editor, you won't see any of the Filetype associations with the .py file, if you edit python in a .txt file. You will lose syntax hilighting, auto completion, language specific refactoring, etc.
Another VERY important point, is that if you are writing multiple files, python won't see the .txt as a python file, and you won't be able to import from it.
So it's always best to write Python in .py files (or .pyx if doing Cython)
For example a README.txt file like you will find in most (if not all) open source projects. (Well, anything on github would probably use .md, but thats a different story)