From anonymous, 1 Month ago, written in Python.
Embed
  1. >>> def print_debug_info(text, verbose=False):
  2. ...     ...
  3. ...
  4. >>> print_debug_info("asfasf")
  5. >>> print_debug_info("asfasf", True)
  6. >>>
  7. >>> print_debug_info("asfasf", verbose=True)
  8. >>> print_debug_info(verbose=True, text="asfasf")
  9. >>> print_debug_info(verbose=True, "asfasf")
  10.   File "<stdin>", line 1
  11.     print_debug_info(verbose=True, "asfasf")
  12.                                            ^
  13. SyntaxError: positional argument follows keyword argument
  14. >>>
  15. >>>
  16. >>> def print_debug_info(text, *, verbose=False):
  17. ...     ...
  18. ...
  19. >>> print_debug_info("asfasf", True)
  20. Traceback (most recent call last):
  21.   File "<stdin>", line 1, in <module>
  22. TypeError: print_debug_info() takes 1 positional argument but 2 were given
  23. >>> print_debug_info("asfasf", True)
  24. Traceback (most recent call last):
  25.   File "<stdin>", line 1, in <module>
  26. TypeError: print_debug_info() takes 1 positional argument but 2 were given
  27. >>> print_debug_info("asfasf", verbose=True)
  28. >>> def print_things(*things):
  29. ...     ...
  30. ...
  31. >>> def print_things(*things):
  32. ...     print(things)
  33. ...
  34. >>> print_things(1, 23, 4)
  35. (1, 23, 4)
  36. >>> print_things(1, 23, 4, 123, 124, 214, 124)
  37. (1, 23, 4, 123, 124, 214, 124)
  38. >>> def print_things(*things, verbose=True):
  39. ...     print(things)
  40. ...
  41. >>> print_things(1, 23, 4, 123, 124, 214, 124, True)
  42. (1, 23, 4, 123, 124, 214, 124, True)
  43. >>> print_things(1, 23, 4, 123, 124, 214, 124, verbose=True)
  44. (1, 23, 4, 123, 124, 214, 124)