fun_calldblstar2.py 509 B

12345678910111213141516171819
  1. # test passing a string object as the key for a keyword argument
  2. try:
  3. exec
  4. except NameError:
  5. print("SKIP")
  6. raise SystemExit
  7. # they key in this dict is a string object and is not interned
  8. args = {'thisisaverylongargumentname': 123}
  9. # when this string is executed it will intern the keyword argument
  10. exec("def foo(*,thisisaverylongargumentname=1):\n print(thisisaverylongargumentname)")
  11. # test default arg
  12. foo()
  13. # the string from the dict should match the interned keyword argument
  14. foo(**args)