You cannot "compile" Python code using Emacs. You can edit Python code. Any file ending in ".py" is automatically edited in Python Mode.