getting name of passed reference

Steve Holden steve at holdenweb.com
Tue Dec 29 11:56:40 EST 2009


Joel Davis wrote:
> On Dec 29, 10:08 am, Steve Holden <st... at holdenweb.com> wrote:
>> 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/
> 
> well not to engage in a he/she said, but in my own defense D'Aprano
> 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 code is and that they should at least
> _try_ the code. Bear in mind that I even told him the reason he wasn't
> able to run it is because he's pasting it into the interactive
> terminal. He then responded back AGAIN with the same insults and the
> same issue that shows he didn't really even read my last response.
> 
> If anything, I should be faulted for actually engaging him and not
> just letting it go.

Yes, that would have been better.

I would be interested to know which response of Steven's you thought
insulting. In reviewing the correspondence the only "insults" I see from
him appear to be (correct) assertions that your code doesn't work under
certain circumstances. Your refutation that "that's probably because it
can't be ran in the interactive terminal" ignores his attempt to help
you avoid real problems, and bypasses his attempt to find out why you
felt it was necessary to obtain the names of things which sometimes
don't have names.

While I have no problem with you ignoring good advice I would prefer it
if you didn't tell knowledgeable and helpful Python programmers to "just
shut up until you know what the hell you are talking about" when they
have already provided long-term evidence by their helpfulness on c.l.py
that they do indeed know what they are talking about. That doesn't
advance any dialog, and isn't normally allowed in the kindergarten
playground, let alone in what purports to be a technical dialog between
responsible adults.

So in future, unless you are *really* sure you are being personally
insulted for no good reason, it would be a much more adult response to
maintain a dignified silence.

Or do you regard this message as insulting also?

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