[Python-Dev] Very Strange Argument Handling Behavior (original) (raw)
Hagen Fürstenau hagen at zhuliguan.net
Fri Apr 16 10:04:38 CEST 2010
- Previous message: [Python-Dev] Very Strange Argument Handling Behavior
- Next message: [Python-Dev] Very Strange Argument Handling Behavior
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] Very Strange Argument Handling Behavior
- Next message: [Python-Dev] Very Strange Argument Handling Behavior
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]