Python equivalent of #line?

François Pinard pinard at iro.umontreal.ca
Sun May 25 09:37:31 EDT 2003


[Gerrit Holl]

> Edward C. Jones schreef op zondag 25 mei om 14:27:34 +0000:
> > C has a preprocessor command
> >   #line n "filename"
> > Can I do this in Python?

> Why do you want that?

For the case you drive generation of Python code from lengthy data files.
You may want tracebacks to refer to your data files instead of generated
Python code, which is not your real sources, nor where you will point your
editor for making the real corrections.

It would be nice if the Python compiler was supporting such directives.
Even if I agree many people would not need it, it would be extremely useful
to those who do.  It would be also useful for developers being able to ask
the Python generator to disregard those `#line' directives when the time
comes to debug the Python generators themselves.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list