Re: getting name of passed reference

2009-12-30 Thread Tim Roberts
Joel Davis wrote: > >Emile, essentially, the situation is that I'm trying to create an API >for consumption scripting. As it stands now, in initial development >they can pass callback function. The idea was to enable them to pass >variables and have the handling function determine the type and jus

Re: getting name of passed reference

2009-12-29 Thread Dave Angel
Joel Davis wrote: On Dec 29, 11:21 am, Emile van Sebille wrote: In an extremely controlled situation you may avoid headaches when deploying this kind of technique. Regardless, we all want to make you aware that this _will_ likely cause headaches, and, idle curiosity aside, none of us can

Re: getting name of passed reference

2009-12-29 Thread Martin P. Hellwig
Joel Davis wrote: I'm just curious if anyone knows of a way to get the variable name of a reference passed to the function. Put another way, in the example: def MyFunc ( varPassed ): print varPassed; MyFunc(nwVar) how would I get the string "nwVar" from inside of "MyFunc"? is it poss

Re: getting name of passed reference

2009-12-29 Thread MRAB
Joel Davis wrote: On Dec 29, 11:21 am, Emile van Sebille wrote: On 12/29/2009 7:02 AM Joel Davis said... On Dec 29, 2:29 am, "Gabriel Genellina" wrote: I'm sure other limitations apply too -- don't rely on this technique for anything critical. -- Gabriel Genellina Gabriel, thanks for your i

Re: getting name of passed reference

2009-12-29 Thread Joel Davis
On Dec 29, 11:21 am, Emile van Sebille wrote: > On 12/29/2009 7:02 AM Joel Davis said... > > > On Dec 29, 2:29 am, "Gabriel Genellina" > > wrote: > >> I'm sure other limitations apply too -- don't rely on this technique for > >> anything critical. > > >> -- > >> Gabriel Genellina > > > Gabriel, >

Re: getting name of passed reference

2009-12-29 Thread Stephen Hansen
On Tue, Dec 29, 2009 at 8:17 AM, Joel Davis wrote: > did set the tone and I think I've been more than a little tolerant on > this. Someone posts a question, responds back with a "n/m I found the > solution, here it is" and his response is essentially to berate them, > telling them how crappy their

Re: getting name of passed reference

2009-12-29 Thread Steve Holden
Joel Davis wrote: > On Dec 29, 10:08 am, Steve Holden wrote: >> Joel Davis wrote: >>> On Dec 29, 2:04 am, Steven D'Aprano >>> wrote: On Mon, 28 Dec 2009 19:28:32 -0800, Joel Davis wrote: > my thanks go out to Emile and Mr Hanson for their responses, I think > I've found the solution,

Re: getting name of passed reference

2009-12-29 Thread Emile van Sebille
On 12/29/2009 7:02 AM Joel Davis said... On Dec 29, 2:29 am, "Gabriel Genellina" wrote: I'm sure other limitations apply too -- don't rely on this technique for anything critical. -- Gabriel Genellina Gabriel, thanks for your input, I had no idea that did that and it could have been deployed

Re: getting name of passed reference

2009-12-29 Thread Joel Davis
On Dec 29, 10:08 am, Steve Holden wrote: > Joel Davis wrote: > > On Dec 29, 2:04 am, Steven D'Aprano > > wrote: > >> On Mon, 28 Dec 2009 19:28:32 -0800, Joel Davis wrote: > >>> my thanks go out to Emile and Mr Hanson for their responses, I think > >>> I've found the solution, much shorter as well

Re: getting name of passed reference

2009-12-29 Thread Steve Holden
Joel Davis wrote: > On Dec 29, 2:04 am, Steven D'Aprano > wrote: >> On Mon, 28 Dec 2009 19:28:32 -0800, Joel Davis wrote: >>> my thanks go out to Emile and Mr Hanson for their responses, I think >>> I've found the solution, much shorter as well: >>> > #!/usr/bin/python >>> > import traceba

Re: getting name of passed reference

2009-12-29 Thread Francesco Bochicchio
On 29 Dic, 00:54, Joel Davis wrote: > I'm just curious if anyone knows of a way to get the variable name of > a reference passed to the function. > > Put another way, in the example: > >   def MyFunc ( varPassed ): >      print varPassed; > >   MyFunc(nwVar) > > how would I get the string "nwVar"

Re: getting name of passed reference

2009-12-29 Thread Joel Davis
On Dec 29, 2:29 am, "Gabriel Genellina" wrote: > En Tue, 29 Dec 2009 00:28:32 -0300, Joel Davis   > escribió: > > > > > On Dec 28, 9:37 pm, Joel Davis wrote: > > my thanks go out to Emile and Mr Hanson for their responses, I think > > I've found the solution, much shorter as well: > > >     > #!

Re: getting name of passed reference

2009-12-29 Thread Joel Davis
On Dec 29, 2:04 am, Steven D'Aprano wrote: > On Mon, 28 Dec 2009 19:28:32 -0800, Joel Davis wrote: > > my thanks go out to Emile and Mr Hanson for their responses, I think > > I've found the solution, much shorter as well: > > >     > #!/usr/bin/python > > >     > import traceback > > >     > def

Re: getting name of passed reference

2009-12-28 Thread Gabriel Genellina
En Tue, 29 Dec 2009 00:28:32 -0300, Joel Davis escribió: On Dec 28, 9:37 pm, Joel Davis wrote: my thanks go out to Emile and Mr Hanson for their responses, I think I've found the solution, much shorter as well: > #!/usr/bin/python > import traceback > def testing ( varPassed

Re: getting name of passed reference

2009-12-28 Thread Steven D'Aprano
On Mon, 28 Dec 2009 19:28:32 -0800, Joel Davis wrote: > my thanks go out to Emile and Mr Hanson for their responses, I think > I've found the solution, much shorter as well: > > > #!/usr/bin/python > > > import traceback > > > def testing ( varPassed ): > > print traceba

Re: getting name of passed reference

2009-12-28 Thread Joel Davis
On Dec 28, 9:37 pm, Joel Davis wrote: > As far as more positive things are concerned, is anyone aware of what > the support for _getframe(1) the way I used it is? Does steven have a > newer (or older) version than me, maybe? (2.6.2) it seems like the > sort of thing that ought to have pretty unifo

Re: getting name of passed reference

2009-12-28 Thread Joel Davis
As far as more positive things are concerned, is anyone aware of what the support for _getframe(1) the way I used it is? Does steven have a newer (or older) version than me, maybe? (2.6.2) it seems like the sort of thing that ought to have pretty uniform behavior, but are their certain calls it var

Re: getting name of passed reference

2009-12-28 Thread Joel Davis
On Dec 28, 8:40 pm, Steven D'Aprano wrote: > On Mon, 28 Dec 2009 17:27:21 -0800, Joel Davis wrote: > > For posterity, I figured out a solution: > > >  > #!/usr/bin/python > > >  > import sys > >  > from traceback import extract_stack > > >  > varPassed="varName get" > > >  > def MyFunc(varPassed):

Re: getting name of passed reference

2009-12-28 Thread Steven D'Aprano
On Mon, 28 Dec 2009 17:27:21 -0800, Joel Davis wrote: > For posterity, I figured out a solution: > > > #!/usr/bin/python > > > import sys > > from traceback import extract_stack > > > varPassed="varName get" > > > def MyFunc(varPassed): > > try: > > raise None >

Re: getting name of passed reference

2009-12-28 Thread Steven D'Aprano
On Mon, 28 Dec 2009 15:54:04 -0800, Joel Davis wrote: > I'm just curious if anyone knows of a way to get the variable name of a > reference passed to the function. > > Put another way, in the example: > > def MyFunc ( varPassed ): > print varPassed; > > MyFunc(nwVar) > > how would I g

Re: getting name of passed reference

2009-12-28 Thread Joel Davis
For posterity, I figured out a solution: > #!/usr/bin/python > import sys > from traceback import extract_stack > varPassed="varName get" > def MyFunc(varPassed): > try: > raise None > except: > frame = sys._getframe(1) >

Re: getting name of passed reference

2009-12-28 Thread Emile van Sebille
On 12/28/2009 3:54 PM Joel Davis said... I'm just curious if anyone knows of a way to get the variable name of a reference passed to the function. For curiosity, sure -- but it's real weak... Put another way, in the example: def MyFunc ( varPassed ): print varPassed; MyFunc(nwVa

Re: getting name of passed reference

2009-12-28 Thread Stephen Hansen
On Mon, Dec 28, 2009 at 3:54 PM, Joel Davis wrote: > I'm just curious if anyone knows of a way to get the variable name of > a reference passed to the function. > > Put another way, in the example: > > def MyFunc ( varPassed ): > print varPassed; > > MyFunc(nwVar) > > how would I get the str

getting name of passed reference

2009-12-28 Thread Joel Davis
I'm just curious if anyone knows of a way to get the variable name of a reference passed to the function. Put another way, in the example: def MyFunc ( varPassed ): print varPassed; MyFunc(nwVar) how would I get the string "nwVar" from inside of "MyFunc"? is it possible? -- http://mai