Python equivt of __FILE__ and __LINE__

Bill Davy Bill at SynectixLtd.com
Mon Feb 11 04:58:54 EST 2008


Writing a quick and dirty assembler and want to give the user the location 
of an error.  The "assembly language" is Python.  If the user wants to 
generat some object code they write something  like:

Label(LoopLable)
    Load(R4)
    Dec()
    JNZ(LoopLabel)

I can use Python to do all the expression evalutaion, conversion from Python 
FP to target FP, include files, macros (done as function definitions).  The 
functions like Load() generate the approproyte object code.

So, for example, when a label is defined or referenced, I save the File,Line 
so if there is not exactly one defintion or no references, I can report the 
file location(s) to be considered.  In the example, I would want to report 
that LoopLable is not referenced, and LoopLabel is not defined.

TIA,
    Bill

PS www.SynectixLtd.com is not relevant 





More information about the Python-list mailing list