Pydoc messed up - * - encoding: utf-8 - * -

I am editing Python scripts using Emacs, and I always put this at the beginning of my scripts:

#!/usr/bin/env python # -*- coding: utf-8 -*- 

Recommended (at least not discouraged) in PEP 0236 .

However, I just found that pydoc does not recognize (ignore) it correctly:

 $ pydoc myscript.py Help on module myscript: NAME myscript - # -*- coding: utf-8 -*- 

Is there any way to fix this? Or a good alternative to using -*- coding: utf-8 -*- ?

I am using Python 2.6

+6
source share
1 answer

It seems that if you really provide the documentation line, the encoding line will be skipped.

File contents:

 #!/usr/bin/env python # -*- coding: utf-8 -*- """Documentation for myscript""" 

pydoc output:

 $ pydoc myscript.py Help on module myscript: NAME myscript - Documentation for myscript 
+7
source

Source: https://habr.com/ru/post/926541/


All Articles