Use list name as string
tino at wildenhain.de
Thu Feb 5 10:39:24 CET 2009
Hendrik van Rooyen wrote:
> "MRAB" <google at mr....ett.plus.com> 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:
print "F(%s) called from '%s' within '%s' line %d" %
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 :-)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3241 bytes
Desc: S/MIME Cryptographic Signature
More information about the Python-list