Re: getting name of passed reference

2009-12-30 Thread Tim Roberts
Joel Davis callmeclaud...@gmail.com 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

Re: getting name of passed reference

2009-12-29 Thread Joel Davis
On Dec 29, 2:04 am, Steven D'Aprano ste...@remove.this.cybersource.com.au 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

Re: getting name of passed reference

2009-12-29 Thread Joel Davis
On Dec 29, 2:29 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 29 Dec 2009 00:28:32 -0300, Joel Davis callmeclaud...@gmail.com   escribió: On Dec 28, 9:37 pm, Joel Davis callmeclaud...@gmail.com wrote: my thanks go out to Emile and Mr Hanson for their responses, I think

Re: getting name of passed reference

2009-12-29 Thread Francesco Bochicchio
On 29 Dic, 00:54, Joel Davis callmeclaud...@gmail.com 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

Re: getting name of passed reference

2009-12-29 Thread Steve Holden
Joel Davis wrote: On Dec 29, 2:04 am, Steven D'Aprano ste...@remove.this.cybersource.com.au 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

Re: getting name of passed reference

2009-12-29 Thread Joel Davis
On Dec 29, 10:08 am, Steve Holden st...@holdenweb.com wrote: Joel Davis wrote: On Dec 29, 2:04 am, Steven D'Aprano ste...@remove.this.cybersource.com.au 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

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 Genellinagagsl-...@yahoo.com.ar 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

Re: getting name of passed reference

2009-12-29 Thread Steve Holden
Joel Davis wrote: On Dec 29, 10:08 am, Steve Holden st...@holdenweb.com wrote: Joel Davis wrote: On Dec 29, 2:04 am, Steven D'Aprano ste...@remove.this.cybersource.com.au 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,

Re: getting name of passed reference

2009-12-29 Thread Stephen Hansen
On Tue, Dec 29, 2009 at 8:17 AM, Joel Davis callmeclaud...@gmail.comwrote: 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

Re: getting name of passed reference

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

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

Re: getting name of passed reference

2009-12-29 Thread Dave Angel
Joel Davis wrote: On Dec 29, 11:21 am, Emile van Sebille em...@fenx.com wrote: snip 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

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? --

Re: getting name of passed reference

2009-12-28 Thread Stephen Hansen
On Mon, Dec 28, 2009 at 3:54 PM, Joel Davis callmeclaud...@gmail.comwrote: 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

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;

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) print

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 get the

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 except:

Re: getting name of passed reference

2009-12-28 Thread Joel Davis
On Dec 28, 8:40 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au 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

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

Re: getting name of passed reference

2009-12-28 Thread Joel Davis
On Dec 28, 9:37 pm, Joel Davis callmeclaud...@gmail.com 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

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

Re: getting name of passed reference

2009-12-28 Thread Gabriel Genellina
En Tue, 29 Dec 2009 00:28:32 -0300, Joel Davis callmeclaud...@gmail.com escribió: On Dec 28, 9:37 pm, Joel Davis callmeclaud...@gmail.com 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