At the start of a python file (first line) sometimes I read

# -*- coding: utf-8 -*-

and sometimes I read

# encoding: utf-8

Both lines seem to do the same thing: specifying utf8 as encoding for all the text put in the file.

I have to questions:

  1. Why does this even work? I thought the interpreter ignores everything after a # because it invokes a comment.
  2. What is the difference between the two lines above? Does the interpreter just ignore the -*-?
Edit
Report