diff options
author | Damien George <damien.p.george@gmail.com> | 2014-06-03 12:53:44 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-06-03 12:53:44 +0100 |
commit | bcb6ca4d5e926d9571d150fb045c5ac4b53f8ecd (patch) | |
tree | 4d230743b401c641bf727adb013d7b5ca1336cdc /tests/basics/dict_update.py | |
parent | 07995e947967b7159cf88c48c2f09463015c1d45 (diff) |
py: Implement full behaviour of dict.update(), and dict().
Add keyword args to dict.update(), and ability to take a dictionary as
argument.
dict() class constructor can now use dict.update() directly.
This patch loses fast path for dict(other_dict), but is that really
needed? Any anyway, this idiom will now re-hash the dictionary, so is
arguably more memory efficient.
Addresses issue #647.
Diffstat (limited to 'tests/basics/dict_update.py')
-rw-r--r-- | tests/basics/dict_update.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/basics/dict_update.py b/tests/basics/dict_update.py index 46d1f41b5..ab1a63304 100644 --- a/tests/basics/dict_update.py +++ b/tests/basics/dict_update.py @@ -8,3 +8,9 @@ print(len(d)) d.update([(1,4)]) print(d[1]) print(len(d)) + +# using keywords +d.update(a=5) +print(d['a']) +d.update([(1,5)], b=6) +print(d[1], d['b']) |