.pythe file is a python script, they must be pure python, IPython will not try magic on it. You must rename your script to .ipyif you want to use syntactic sugar. IPython suggestions on top of pure python syntax.
, IPython python (cf %hist vs %hist -t), python, IPython.