Hendrik van Rooyen wrote: > "MRAB" <[email protected]> wrote: > >> The actual names of the variables and functions shouldn't matter to the >> outside world; the name of an output file shouldn't depend on the name >> of a variable. > > That is a matter of opinion. > It is however, an interesting problem, namely: > > How does one get hold of the actual name by which some parameter > is passed? > > you may want to print, as a debug thingy: > > print "the name passed in was: ", ImpossibleThingYieldingName > print "and it evaluates to:" , ArgumentPassed
This is possible to some degree:
import inspect
def F(a):
frame_obj,filename,line_no,
func_name,contextlines,
contextindex=(inspect.getouterframes(inspect.currentframe()))[1]
print "F(%s) called from '%s' within '%s' line %d" %
(repr(a),filename,func_name,line_no)
for ln,srcline in enumerate(contextlines or []):
print "%3s : %s" % ('*>' if ln==contextindex else '',srcline)
just play around calling the above function from different
places and you should see what I mean :-)
Regards
Tino
smime.p7s
Description: S/MIME Cryptographic Signature
-- http://mail.python.org/mailman/listinfo/python-list
