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