Python equivalent of #line?

François Pinard pinard at iro.umontreal.ca
Sun May 25 15:21:52 EDT 2003


[Bengt Richter]

> On 25 May 2003 09:37:31 -0400, pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois_Pinard?=) wrote:

> >[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.

> If you were e.g., generating gen.py from gdata.txt, you could at the same
> time generate a vim tag file to translate key line locations of gen.py to
> gdata.txt locations [...]

Indeed, this might cleverly help at edit time.  On the other hand, it
creates some burden on the shoulders of developers for generating these tag
files, keeping them in sync, distributing them, explaining other users how
to use them, etc.  We would need to generate `tags' for `vim' and a
differently formatted `TAGS' for Emacs; while many other editors just do not
support such files.  Finally, the ability of tracebacks to quote one source
line per traceback level would not necessarily be served as we would expect.

It might be more functional and useful if supported by the Python compiler.

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





More information about the Python-list mailing list