How to get the 'name' of an int
Just
just at xs4all.nl
Fri Feb 28 04:46:28 EST 2003
In article <b3najo$hej$1 at reader08.wxs.nl>,
"Hans Brand" <Hans.Brand at BrandInnovators.com> wrote:
> Hi,
>
> I would like to get the 'name' of a variable to do something like this:
>
> causea = 12
> causeb = 13
> for cause in (causea, causeb):
> print "%s = %s" %(name(cause), cause)
>
> The result should be:
> causea = 12
> causeb = 13
>
> How can I achieve this?
You can't and you don't... Objects don't know to which name(s) they're
bound to. Imagine this:
causea = 12
causeb = 13
causec = causea
You need to "reset your brain":
http://effbot.org/guides/python-objects.htm
HTH,
Just
More information about the Python-list
mailing list