.py - Python source code - textual representation of the program in Python
Python source files normally have extension .py. Python saves the compiled bytecode file
for each module in the same directory as the module's source, with the same basename and extension .pyc (or .pyo if Python is run with option -O).
- .pyc - Python byte code - the partially compiled program, saved for future use so as to speed up program loading. See here for details. The bytecode the program is stored in is platform-independent.
- .pyo - Python optimized byte code - more or less equivalent to .pyc, except that some debugging information is removed
.pyw - pyw means run the script without invoking the console window, especially if your program is GUI based. If you rename the file to py extension,you still can run it. The .pyw script is called by pythonw.exe. (as opposed to python.exe)
To be noted: .py file runs on console basis that is using command prompt or terminal and .pyw files are used when you are building a GUI application and not a console application using Qt or Jython and some other tools which help in Python GUI programming