MCPcopy Index your code
hub / github.com/webpy/webpy / first

Method first

web/utils.py:673–683  ·  view source on GitHub ↗

Returns the first element of the iterator or None when there are no elements. If the optional argument default is specified, that is returned instead of None when there are no elements.

(self, default=None)

Source from the content-addressed store, hash-verified

671 self.i, self.c = iterator, 0
672
673 def first(self, default=None):
674 """Returns the first element of the iterator or None when there are no
675 elements.
676
677 If the optional argument default is specified, that is returned instead
678 of None when there are no elements.
679 """
680 try:
681 return next(iter(self))
682 except StopIteration:
683 return default
684
685 def __iter__(self):
686 if hasattr(self, "_head"):

Callers

nothing calls this directly

Calls 1

nextFunction · 0.85

Tested by

no test coverage detected