2016-05-07 22:02:46 +01:00
|
|
|
# test passing a user-defined mapping as the argument to **
|
|
|
|
|
|
|
|
def foo(**kw):
|
|
|
|
print(sorted(kw.items()))
|
|
|
|
|
|
|
|
class Mapping:
|
|
|
|
def keys(self):
|
2017-01-17 05:03:30 +00:00
|
|
|
# the long string checks the case of string interning
|
|
|
|
return ['a', 'b', 'c', 'abcdefghijklmnopqrst']
|
2016-05-07 22:02:46 +01:00
|
|
|
|
|
|
|
def __getitem__(self, key):
|
|
|
|
if key == 'a':
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
return 2
|
|
|
|
|
|
|
|
foo(**Mapping())
|