Python equivalent of #line?

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


[Thomas Guettler]
> [François Pinard]
> > [Gerrit Holl]
> > > [Edward C. Jones]

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

> I think automatically creating python code is a bad idea.  I once had to
> deal with an old project which stored data in the syntax of a programming
> language.  It is hell.  Data should be in a format suitable for data.

Python source is very suitable for expressing data, you know.  I have many
cases where this is far more like a blessing than like hell.  I guess, from
the mere words we are using, that this may become a religious debate! :-)

For the original case under discussion, however, I think the point was about
Python executable code generated from data files that could hold, for
example, either Python snippets, or algorithms expressed in other languages.
In such cases, `#line'-like directives would be especially useful.

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





More information about the Python-list mailing list