You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dict creates a dictionary. It accepts up to one positional argument, which is interpreted as an iterable of two-element sequences (pairs), each specifying a key/value pair in the resulting dictionary.
In reality, the Java implementation allows the positional argument to also be another dictionary, in which case the entries of that dictionary are included in the new one. Note that this is a distinct case because iterating over dictionaries yields their keys, not their key-value pairs.
The Java implementation's behavior is consistent with Python. But in reality, it should be generalized to also extend to other user-defined mapping types. The concept of Mapping is already defined in the spec.
The text was updated successfully, but these errors were encountered:
For reference, in Python, the criteria for treating the positional argument to dict() as a mapping rather than an iterable appears to be that it has the keys() and __getitem__() methods.
The current verbiage is:
In reality, the Java implementation allows the positional argument to also be another dictionary, in which case the entries of that dictionary are included in the new one. Note that this is a distinct case because iterating over dictionaries yields their keys, not their key-value pairs.
The Java implementation's behavior is consistent with Python. But in reality, it should be generalized to also extend to other user-defined mapping types. The concept of
Mapping
is already defined in the spec.The text was updated successfully, but these errors were encountered: