Run Python 3 in TextMate (Mac)

I was having an issue with TextMate 2.0 in that it runs Python 2, even after installing IDLE with Python 3. For example:

a=5
print("Total:", a)

Resulted in: (‘Total:’, 5)

Instead of: Total: 5

From what I read, it is best to have TextMate use Python 3 on a per project basis; changing defaults can break other parts since it uses Python 3. 

The solution here from “philbernt” was the most straight-forward solution.

First, launch terminal and type:

which python3

On my machine the following was returned:

/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

In your TextMate document, after selecting Python as the document type, copy and past the result from Terminal, proceeded by “#!”. In my example this would be:

#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

Use Command R to run and it should now run with the latest version of Python.