> 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4