Meta Line information in Python?

Tan Woon Kiong thomas_sg2000 at yahoo.com
Thu Jul 4 04:09:26 EDT 2002


Hi,

Is there a way to specify meta line information in Python? 

For instance, in C language, this can be done by writing the statement
  #line <line-no> "<src file>"

For example, the following line in a file "el2h.py"
  #line 79 "el2h.nw"
means that the next statement comes from line 79 of the file
"el2h.nw".

Such meta line information is needed when the python code is generated
from other files and not coded directly by the programmer. I need this
facility as I use noweb, a literate programming tool, to write python
code. So the python code "el2h.py" is actually generated from the
literate source "el2h.nw". I need the python interpreter to report any
error message with line number pointing to the literate source
"el2h.nw" and not the generated code "el2h.py".

Regards,
- Woon Kiong



More information about the Python-list mailing list