how do you get the name of a dictionary?

Duncan Booth duncan.booth at invalid.invalid
Fri Aug 25 04:30:46 EDT 2006


Steven D'Aprano wrote:

>>>>>> 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.
> 
I think you've missed the point that with the code you posted you raise the 
ValueError unconditionally, so x isn't *any* of a, b, c, or d.

Perhaps, if you had produced a code sample where you tested some values for 
being in a suitable range and it wasn't obvious from the traceback which 
value was affected, you might have managed to make your point? Or perhaps 
you would have found it harder to obfuscate the code than you think it is. 

With the code you posted though, I'm afraid Frederik's observation was spot 
on.




More information about the Python-list mailing list