[Python-Dev] #pragmas in Python source code

M.-A. Lemburg mal@lemburg.com
Wed, 12 Apr 2000 18:12:59 +0200


Peter Funk wrote:
> 
> Fred L. Drake, Jr.:
> > M.-A. Lemburg writes:
> >  > Here's a simple strawman for the syntax:
> > ...
> >  > The compiler would scan these pragma defs, add them to an
> >  > internal temporary dictionary and use them for all subsequent
> >  > code it finds during the compilation process. The dictionary
> >  > would have to stay around until the original compile() call has
> >  > completed (spanning recursive calls).
> >
> > Marc-Andre,
> >   The problem with this proposal is that the pragmas are embedded in
> > the comments; I'd rather see a new keyword and statement.  It could be
> > defined something like:
> >
> > pragma_atom: NAME | NUMBER | STRING+
> > pragma_stmt: 'pragma' NAME ':' pragma_atom (',' pragma_atom)*
> 
> This would defeat an important goal: backward compatibility: You
> can't add 'pragma division: old' or something like this to a source
> file, which should be able to run with both Python 1.5.2 and Py3k.
> This would make this mechanism useless for several important
> applications of pragmas.

Hmm, I don't get it: these pragmas would set variabels which
make Python behave in a different way -- how do you plan to
achieve backward compatibility here ?

I mean, u = u"abc" raises a SyntaxError in Python 1.5.2 too...

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/