getting name of passed reference

Joel Davis callmeclaudius at gmail.com
Tue Dec 29 11:17:05 EST 2009


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.



More information about the Python-list mailing list