Nandeesh Mp Developer & Open Source Enthusiast

Encoding Python Source Files.

Python interpreter defaults to ASCII as default encoding, if no encoding is specified. To specify encoding one can place below line as firts or second line in the source files.

Specifing Encoding

# * coding: _*_

Example Encoding

# * coding: utf-8 *

Encoding can be specified in couple of more formats. In short, it has to match below regular expression.

Encoding regex

^[ \t\v]#.?coding[:=][ \t]*([-_.a-zA-Z0-9]+)

[[ alt=python-encoding]]