I edit Python scripts with Emacs, and I always put this at the beginning of my scripts:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
It is recommended (at least, not discourage) in PEP 0236.
However, I just found that pydoc
doesn't recognize (ignore) it correctly:
$ pydoc myscript.py
Help on module myscript:
NAME
myscript - # -*- coding: utf-8 -*-
Is there a way to fix that? Or a good alternative to using -*- coding: utf-8 -*-
?
I'm using Python 2.6
It appears that if you actually provide a documentation string 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With