PEP218: Representing the empty set
Paul Rubin
http
Tue Feb 17 16:22:54 EST 2004
Peter Hansen <peter at engcorp.com> writes:
> Maybe it's nothing more than this distinction: dict() is a call which
> *returns* an empty dictionary. {} *is* an empty dictionary.
I don't understand in what ways these are really distinct.
a = []
for i in range(2):
a.append({})
print (a[0] is a[1])
prints 0, if that helps. Clearly "a = {}" and "a = dict()" both run
some code that creates a new empty dictionary. It's not the case that
"a = {}" sets a to an empty dict created at compile time or anything
like that.
More information about the Python-list
mailing list