On 2/18/06, James Y Knight <foom at fuhm.net> wrote: > On Feb 18, 2006, at 2:33 AM, Martin v. Löwis wrote: > > Well, as you say: you get a KeyError if there is an error with the > > key. > > With a default_factory, there isn't normally an error with the key. > > But there should be. Consider the case of two servers. One which > takes all the items out of the dictionary (using items()) and puts > them in some other data structure. Then it checks if the "Date" > header has been set. It was not, so it adds it. Consider another > similar server which checks if the "Date" header has been set on the > dict passed in by the user. The default_factory then makes one up. > Different behavior due to internal implementation details of how the > server uses the dict object, which is what the restriction to > _exactly_ dict prevents. It just occured to me, what affect does this have on repr? Does it attempt to store the default_factory in the representation, or does it remove it? Is it even possible to store a reference to a builtin such as list and have eval restore it? -- Adam Olsen, aka Rhamphoryncus
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