2016-05-07 17:02:46 -04: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 00:03:30 -05:00
|
|
|
# the long string checks the case of string interning
|
|
|
|
return ['a', 'b', 'c', 'abcdefghijklmnopqrst']
|
2016-05-07 17:02:46 -04:00
|
|
|
|
|
|
|
def __getitem__(self, key):
|
|
|
|
if key == 'a':
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
return 2
|
|
|
|
|
|
|
|
foo(**Mapping())
|