Python's 8-bit cleanness deprecated?

Andrew Bennetts andrew-pythonlist at puzzling.org
Wed Feb 5 05:18:19 EST 2003


On Wed, Feb 05, 2003 at 10:54:53AM +0100, Anders J. Munch wrote:
> "Andrew Bennetts" <andrew-pythonlist at puzzling.org> wrote:
> > On Tue, Feb 04, 2003 at 11:03:50AM +0100, Anders J. Munch wrote:
> > > 
> > > Now to define a not-in-comment syntax, that trivial.  Just remove the
> > > in-comment part and write, as a statement:
> > > 
> > > -*- coding: Latin-1 -*-
> > 
> > What about:
> >     from __encodings__ import -*- coding: Latin-1 -*-
> > 
> > <wink>
    ^^^^^^
    Note the wink :)

> > the-best-of-both-worlds-ly yrs, -Andrew.
> 
> He he.  I'm not sure if you're laughing with me or at me.  In any

I'm laughing with you :)

> case, you should know that I'm dead serious: If
>    # -*- coding: Latin-1 -*-
> is a good idea then 
>    -*- coding: Latin-1 -*-
> is a better one.
> 
> I'm not saying that dash-star-dash is a good idea, I'm not saying that
> it isn't.  But whatever we do, the Python interpreter should never
> execute the contents of comments.

I agree in principle, but I just realised a possibly strong argument in favour
of putting the encoding in a comment: with your proposal, how would you
write a unicode source file that worked in both Python 2.3 and older Pythons
(e.g. 1.5.2)?

Then again, it perhaps isn't even possible to write a unicode source file
that works for 1.5.2 no matter what you do (unless you stick to e.g. plain
ASCII, which is technically also correct UTF-8), so perhaps this isn't a
real problem.  I don't know enough about unicode to know.

Anyway, being an English speaker, the end result isn't going to bother me
much whatever happens... the default encoding of UTF-8 is more than adequate
for my simple needs.

-Andrew.






More information about the Python-list mailing list