overloading *something

Ron Adam rrr at ronadam.com
Tue Nov 8 00:01:00 EST 2005



Alex Martelli wrote:
> Ron Adam <rrr at ronadam.com> wrote:
> 
> 
>>James Stroud wrote:

>>>And, how about the "**something" operator?
>>>
>>>James
>>
>>A dictionary would be pretty much the same except subclassed from a 
>>dictionary of course.
> 
> 
> I believe this one is correct (but I have not checked in-depth!).
> 
> 
> Alex

A quick test shows the error message to be very specific in this case, 
where as the *something error message requests a more general sequence.


 >>> def foo(**b): pass
...
 >>> class a: pass
...
 >>> foo(**a)
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
TypeError: foo() argument after ** must be a dictionary


Ron



More information about the Python-list mailing list