Re: Printing a variable's name not its value

2005-07-20 Thread travislspencer
[EMAIL PROTECTED] wrote: > Bruno Desthuilliers wrote: > > def printVerbose(*args, **kwargs): > > > > > if VERBOSE in globals: > > > for a in args: > > > if a in globals: > > > value = globals[a] > > for k, v in kwargs.iteritems(): > > >

Re: Printing a variable's name not its value

2005-07-20 Thread tiissa
Simon Dahlbacka wrote: > as you have been told, there is no way to get a variable's name Well, if you really want to, you can get all the names bound to a given object: def get_names(obj): g = globals() names = [] for name in g: if g[name] is obj: names.appe

Re: Printing a variable's name not its value

2005-07-20 Thread travislspencer
Simon Dahlbacka wrote: > as you have been told, there is no way to get a variable's name, take a > look at http://effbot.org/zone/python-objects.htm to find out why this > is so. Thanks, Simon, for the link. -- Regards, Travis Spencer -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing a variable's name not its value

2005-07-20 Thread travislspencer
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : > > globals = {} > > globals() is a builtin function, you should no shadow it. Oh, woops. I'll fix that. > def printVerbose(*args, **kwargs): > > > if VERBOSE in globals: > > for a in args: > > if a in globals: > >

Re: Printing a variable's name not its value

2005-07-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hey, > > I am trying to write a function that takes an arbitrary number of > arguments and does one of two things. If the variable is a key in a > dictionary, it prints the key and its value. Otherwise, if any of the > variables isn't in the dictionary, the function

Re: Printing a variable's name not its value

2005-07-20 Thread Simon Dahlbacka
as you have been told, there is no way to get a variable's name, take a look at http://effbot.org/zone/python-objects.htm to find out why this is so. -- http://mail.python.org/mailman/listinfo/python-list

Printing a variable's name not its value

2005-07-20 Thread travislspencer
Hey, I am trying to write a function that takes an arbitrary number of arguments and does one of two things. If the variable is a key in a dictionary, it prints the key and its value. Otherwise, if any of the variables isn't in the dictionary, the function prints the variable's name and value.