PEP: Defining Python Source Code Encodings

Bruce Sass bsass at
Tue Jul 17 22:47:32 CEST 2001



> >Generally:  #<magic> <directive> [<arguments>]

or as I should have written it...

#<magic><directive> [<arguments>]

> I withdraw my #!pragma (or #!pythma ;-) suggestion and propose
> r'^\s*#pragma\s' as the magic line prefix regular expression.

Why is "pragma" better <magic> than " ## ", or some other sequence of
non-word characters?

I would think that using any *word* as the <magic> is just asking for
trouble; someone is bound to have done (or normally does) a
block of comments where there is no space between the "#" and the
first word of the comment (iirc, emacs handles comments in such a way
that "#comments" is the right thing to do in some cases)... is the
word "pragma" now illegal as the first word in such a comment, what
does this do to any tools that automatically turn arbitrary text into

- Bruce

More information about the Python-list mailing list