Python equivalent of #line?

Edward C. Jones edcjones at erols.com
Sun May 25 11:28:05 EDT 2003


François 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.

That is exactly what I am doing.

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

Agreed.





More information about the Python-list mailing list