[Python-ideas] dict(default=int)

Erik python at lucidity.plus.com
Thu Mar 9 19:29:09 EST 2017


On 09/03/17 23:04, Spencer Brown wrote:
> Might make more sense to be dict.default(int), that way it doesn't
> have redundant dict names.

I thought that, too.

> since you could do {1:2, 3:4}.default(int)

Could you?

Python 3.6.0 (default, Mar  9 2017, 00:43:06)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> type(dict())
<class 'dict'>
 >>> type({})
<class 'dict'>
 >>> type(dict)
<class 'type'>

The thing bound to the name 'dict' is not the same as the object 
returned by _calling_ 'dict'.

E.


More information about the Python-ideas mailing list