learning python. learning defining functions . need help
Random832
random832 at fastmail.com
Fri Jul 22 11:35:02 EDT 2016
On Fri, Jul 22, 2016, at 11:21, justin walters wrote:
> Try opening the interactive terminal on your command line and type the
> following:
>
> type({}) == dict()
>
> That should illustrate why.
That doesn't illustrate anything relevant at all. The reason this is
false is because dict() is a dict instance, not the dict type.
type({}) == dict == type(dict()) will always* be true.
>This is because simply typing '{}' could be interpreted as either a
>dict or a set. My interpreter defaults 'type({})' to 'dict', but it's
>best to not take the risk.
This is part of the language spec, it is not something that can be
chosen by each interpreter.
*well, assuming that "type" and "dict" have not been reassigned from
their built-in definitions.
More information about the Python-list
mailing list