Python equivalent of #line?

Greg Ewing (using news.cis.dfn.de) g2h5dqi002 at sneakemail.com
Sun May 25 23:04:50 EDT 2003


Thomas Guettler wrote:
> 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.

Generating Python code from another programming language
wouldn't be such a bad idea, though. One of my potential
future projects, for example, involves taking a file of
SQL statements and generating Python functions which
wrap them.

It occurs to me that one might be able to hack the
line number table in the bytecode, if one were feeling
brave enough -- it's stored in a rather funky format.

It would be nice to have a nicer way, though. Maybe
something like

__line__ = <const>

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg





More information about the Python-list mailing list