builtin_next_arg2.py 309 B

123456789101112
  1. """
  2. categories: Modules,builtins
  3. description: Second argument to next() is not implemented
  4. cause: MicroPython is optimised for code space.
  5. workaround: Instead of ``val = next(it, deflt)`` use::
  6. try:
  7. val = next(it)
  8. except StopIteration:
  9. val = deflt
  10. """
  11. print(next(iter(range(0)), 42))