how do you get the name of a dictionary?

Steven D'Aprano steve at REMOVEME.cybersource.com.au
Fri Aug 25 00:13:48 EDT 2006


On Wed, 23 Aug 2006 12:16:45 +0200, Fredrik Lundh wrote:

> Steven D'Aprano wrote:
> 
>> Here's a traceback. One of the arguments to spam() is too small. Can you
>> tell which one just by looking at the traceback?
>>
>>>>> a, b, c, d = range(4)
>>>>> spam(a, b, c, d)
>> Traceback (most recent call last):
>>  File "<stdin>", line 1, in ?
>>  File "<stdin>", line 6, in spam
>>  File "<stdin>", line 5, in eggs
>>  File "<stdin>", line 4, in beans
>> ValueError: x is too small
>>
>> Of course you can't. x could be any one of a, b, c or d, and the traceback
>> doesn't give you enough information to tell which.
> 
> for some reason, your example gives a different error on my machine:
> 
>     StrawManError: Attempt to construct Reductio ad absurdum argument failed

Sheesh Fredrik, what's eating you? I'm trying to have a civil discussion,
and you're being deliberately obtuse.

If I'm factually wrong, if I've made an error of fact or logic, and
somebody points out where the error lies, I will accept that. I am always
willing to learn. But making fatuous, and false, accusations of strawman
and reductio ad absurdum fallacies doesn't invalidate my point that there
are occasions where the traceback refers to a object with one name, but
the object was created in a different scope with a different name. I'm not
making an extraordinary claim here -- what I said should be so obvious it
verges on the banal. The traceback reports the name of the object in the
scope the error occurred in. The line of code responsible for putting the
wrong data into that object can occur in a different scope, with a
different name. Is that really so hard to grasp?

I don't know what more I can do to get through to you that I *don't*
expect Python's object model to change to fix this one single issue. I've
said it AT LEAST twice times so far: such a change would be a lot of cost
for very minimal benefit. But after the undeserved roasting that Jojoba
received, it is only right to that we recognise that there are valid cases
for objects to know their own name -- even if, in the majority of cases,
those valid uses aren't worth the cost of implementing them.


-- 
Steven D'Aprano 




More information about the Python-list mailing list