Use list name as string
Hendrik van Rooyen
mail at microcorp.co.za
Thu Feb 5 08:03:03 CET 2009
"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
you may want to print, as a debug thingy:
print "the name passed in was: ", ImpossibleThingYieldingName
print "and it evaluates to:" , ArgumentPassed
to help you see from where your function was called,
and you can't, as far as I know, do this, because there
is no backwards link from the object to all of its various names.
And while the OP can solve his problem by passing in the name explicitly,
as doStuff("banana",banana) it will do him no good if he gets the list
returned from something else:
Because in such a situation there is no backwards link to a name.
So to the OP :
Sorry - you can't get there from here.
More information about the Python-list