Take the following code:
#! /usr/bin/env python2.5
# -*- coding: utf-8 -*-
thing = u'\N{DEGREE SIGN}'
print thing
This will run in OS X terminal without error, but when run through the Textwrangler Python interpreter, it throws an error. However, when I flip the first two lines, it runs without error in both places:
# -*- coding: utf-8 -*-
#! /usr/bin/env python2.5
thing = u'\N{DEGREE SIGN}'
print thing
I was under the impression that the shebang needed to be in the first two bytes of the file, so I presume that it's being ignored in the second example. I was further under the impression that convention dictated that this is the proper way to kick off the script:
#! /usr/bin/env python2.5
# -*- coding: utf-8 -*-
But that doesn't seem to be the case in all instances.
Is there something with Textwrangler here that I'm missing?
[EDIT] My use case (Python 2.5) is at minimum a large part of what is causing the problem.
[UPDATE] The following runs error-free in Terminal and TextWrangler:
#! /usr/bin/env python2.5
# -*- coding: utf-8 -*-
degreeSign = u'\u00B0'
degreeSign_encoded = degreeSign.encode('utf-8')
print degreeSign_encoded