getting name of passed reference

Steve Holden steve at holdenweb.com
Tue Dec 29 10:08:24 EST 2009


Joel Davis wrote:
> On Dec 29, 2:04 am, Steven D'Aprano
> <ste... at 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.

Whereas you appear to have a problem maintaining good manners.

regards
 Steve
-- 
Steve Holden           +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC                 http://www.holdenweb.com/
UPCOMING EVENTS:        http://holdenweb.eventbrite.com/




More information about the Python-list mailing list