J
Joakim Hove
Hello,
i have simple[1] function like this:
def log_msg(msg , file , line):
print "%s:%s %s" % (file,line,msg)
the file and line arguments should be the filename and linenumber of
the source file where the function is called. If this were C I would
have used the __FILE__ and __LINE__ macros as:
log_msg(msg , __FILE__ , __LINE__)
Is there a way to emulate this behaviour in Python?
Best Regards
Joakim Hove
[1]: It is not *that* simple, but you get the point.
--
Joakim Hove
hove AT ntnu.no /
Tlf: +47 (73 5)9 34 27 / Stabburveien 18
Fax: ................. / N-5231 Paradis
http://www.ift.uib.no/~hove/ / 55 91 28 18 / 92 68 57 04
i have simple[1] function like this:
def log_msg(msg , file , line):
print "%s:%s %s" % (file,line,msg)
the file and line arguments should be the filename and linenumber of
the source file where the function is called. If this were C I would
have used the __FILE__ and __LINE__ macros as:
log_msg(msg , __FILE__ , __LINE__)
Is there a way to emulate this behaviour in Python?
Best Regards
Joakim Hove
[1]: It is not *that* simple, but you get the point.
--
Joakim Hove
hove AT ntnu.no /
Tlf: +47 (73 5)9 34 27 / Stabburveien 18
Fax: ................. / N-5231 Paradis
http://www.ift.uib.no/~hove/ / 55 91 28 18 / 92 68 57 04