Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 5 years ago

Iguananaut gravatar image

Since you cited PEP-263, read carefully the regular expression it gives for what the coding line should match:

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

specifically, the string coding should be immediately followed by a : or =, no whitespace. The encoding name UTF-8 is fine since encoding names are not case-sensitive.

The most common way to write this is:

```

-- coding: utf-8 --

click to hide/show revision 2
No.2 Revision

Since you cited PEP-263, read carefully the regular expression it gives for what the coding line should match:

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

specifically, the string coding should be immediately followed by a : or =, no whitespace. The encoding name UTF-8 is fine since encoding names are not case-sensitive.

The most common way to write this is:

```

-- coding: utf-8 --

```

click to hide/show revision 3
No.3 Revision

Since you cited PEP-263, read carefully the regular expression it gives for what the coding line should match:

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

specifically, the string coding should be immediately followed by a : or =, no whitespace. The encoding name UTF-8 is fine since encoding names are not case-sensitive.

The most common way to write this is:

```

-- coding: utf-8 --

```

click to hide/show revision 4
No.4 Revision

Since you cited PEP-263, read carefully the regular expression it gives for what the coding line should match:

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

specifically, the string coding should be immediately followed by a : or =, no whitespace. The encoding name UTF-8 is fine since encoding names are not case-sensitive.

The most common way to write this is:

```

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

-*-

```

click to hide/show revision 5
No.5 Revision

Since you cited PEP-263, read carefully the regular expression it gives for what the coding line should match:

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

specifically, the string coding should be immediately followed by a : or =, no whitespace. The encoding name UTF-8 is fine since encoding names are not case-sensitive.

The most common way to write this is:

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

Note: Since this is just a standard Python feature it is not specific to Sage, so you could also likely find answers to your problem on StackOverflow or any other source for Python help.