Raymond Hettinger wrote: >> - It would be unwise to have a default value that would be called if >> it was callable: what if I wanted the default to be a class instance >> that happens to have a _call_ method for unrelated reasons? >> Callability is an elusive propperty; APIs should not attempt to >> dynamically decide whether an argument is callable or not. > > That makes sense, though it seems over-the-top to need a zero-factory > for a multiset. > > An alternative is to have two possible attributes: > d.default_factory = list > or > d.default_value = 0 > with an exception being raised when both are defined (the test is > done when the > attribute is created, not when the lookup is performed). What does this buy over just doing: d.default_factory = lambda: 0 which is also totally unambiguous wrt the semantic of usage of the default value (copy vs deepcopy vs whatever)? Given that the most of the default values I have ever wanted to use do not even require a lambda (list, set, int come to mind). -- Giovanni Bajo
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