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 traceback > > > > def testing ( varPassed ): > > > print traceback.extract_stack()[0][3] > > > > testing("123") > > > and it seems the traceback module in general seems to have a lot of > > history to it. This project is for CPython so compatibility with Jython, > > Iron Python, et al isn't really that important right now. So as far as > > functionality and compatibility I think I'm set as long as > > traceback.extract_stack is 3.0 safe. > > I'm afraid that one fails again. Do you actually test your solutions > before telling us you've solved the problem? > > >>> import traceback > >>> def testing ( varPassed ): > > ... print traceback.extract_stack()[0][3] > ... > > >>> testing("123") > None > >>> x = "123" > >>> testing(x) > > None > > When a "solution" doesn't work under some circumstances (in this case, > when run in the interactive interpreter) that's a warning that you need > to understand when and where it will work before using it in production. > Otherwise, how do you know that it will work under other circumstances? > > Or, find an alternative. What are you actually trying to do? "Get the > name of a passed reference" is a means to an end. What are you expecting > to do with it? > > -- > Steven
Steven I don't know what your issue is, but it works for me. If your having trouble running the code, then that's your issue, and I would appreciate it if you would just shut up until you know what the hell you're talking about. I say that because if you paid the slightest attention my first solution that you found so woefully inept IS BASICALLY YOUR FIRST SOLUTION RECONFIGURED. You also apparently can't read. -- http://mail.python.org/mailman/listinfo/python-list