views:

1179

answers:

6

I need to include a copyright statement at the top of every Python source file I produce:

#   Copyright: © 2008 etc.

However, when I then run such a file I get this message:

SyntaxError: Non-ASCII character '\xa9' in file MyFile.py on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details.

Apparently Python isn't happy about the copyright symbol because it assumes the source file is all in ASCII. Either I need to make my first line be:

# -*- coding: iso-8859-1 -*-

to tell Python I'm using Latin encoding, or I can change the copyright statement to:

#   Copyright: \xa9 2008 etc.

which just possibly doesn't have the same legal standing.

Is there a more elegant solution?

+17  A: 

The copyright symbol in ASCII is spelled (c) or "Copyright".

See circular 61, Copyright Registration for Computer Programs.

While it's true that the legal formalism (see Circular 1, Copyright Basics) is

The symbol © (the letter C in a circle), or the word “Copyright,” or the abbreviation “Copr.”; and...

And it's also true that

To guarantee protection for a copyrighted work in all UCC member countries, the notice must consist of the symbol © (the word “Copyright” or the abbreviation is not acceptable)

You can dig through circular 3 and 38a.

This has, however, already been tested in court. It isn't an interesting issue. If you do a search for "(c) acceptable for c-in-a-circle", you'll find that lawyers all agree that (c) is an acceptable substitute. See Perle and Williams. See Scott on Information Technology Law.

S.Lott
Thanks. Elegant, and embarrassingly simple.
Charles Anderson
(c) is not a legally valid substitute. Strictly speaking, you could just as well leave it out. - http://desktoppub.about.com/cs/finetypography/ht/copyright_tm.htm
Deestan
Are you sure? I've just noticed this output from Visual Studio: Copyright (C) Microsoft Corporation. All rights reserved.
Charles Anderson
+2  A: 

You can always revert to good old (c)

Alexander Kojevnikov
+2  A: 

Waiting for Python 3k, where the default encoding of the source will be UTF-8?

bortzmeyer
Or use Python 2.2, before this was introduced ;)
Tony Meyer
Python 3K is out now :-)
bortzmeyer
+8  A: 

Contrary to the accepted answer, AFAIK, (c) is not an officially recognized alternative to the copyright symbol, although I'm not sure it's been tested in court.

However, © is just an abreviation of the word Copyright. Saying "Copyright 2008 Robert Munro" is identical to saying "© 2008 Robert Munro"

Your "Copyright: © 2008 etc." Expands to "Copyright: Copyright 2008 etc."

Wikipedia's page seems to agree with me http://en.wikipedia.org/wiki/Copyright_symbol

In the United States, the copyright notice consists of three elements: 1. the © symbol, or the word "Copyright" or abbreviation "Copr."; ...

rjmunro
It has been tested in court. (c) is an acceptable substitute.
S.Lott
A: 

Answers to this question, particularly @Ben Combee's answer, should be helpful.

Scottie T
+1  A: 

For Python 2, the "right" thing to do is to specify the encoding, or never use non-ASCII characters. Specifying the encoding makes it simpler on the compiler and on humans. Sorry, but Python originally specified ASCII as the default, back in the Dark Ages.

For Python 3, UTF-8 is the default encoding, so you should be fine. In that case I would recommend not specifying the encoding if you use the default.

Whether a language allows/requires an encoding specification or not, in the age of Unicode this is an issue we need to keep in mind for every "text" file.

A. L. Flanagan