> This behavior seems pretty strange to me, indeed PyPy gives the
> TypeError for both attempts.  I just wanted to confirm that it was in
> fact intentional.

Oleg already answered why f(**{1:3}) raises a TypeError. But your
question seems to be rather why dict(**{1:3}) doesn't.

For functions implemented in Python, non-string arguments are always
rejected, but C functions (like the dict constructor) don't have to
reject them. I don't see any benefit in allowing them, but it's probably
not worth breaking code by disallowing them either.

I couldn't find this documented. Perhaps we should just say "don't rely
on being able to pass non-string keywords" somewhere?

- Hagen
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to