Skip to content

Commit

Permalink
ubuiltins: Document iter, enumerate, map.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Nov 28, 2022
1 parent 9578fc1 commit 84d1d7b
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/ubuiltins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,11 @@ def __init__(self, iterable: Iterable, start: _int) -> None:

def __init__(self, *args) -> None:
"""
Returns an enumerate object.
enumerate(iterable, start=0)
Equivalent to::
Enumerates an existing iterator by adding a numeric index.
This function is equivalent to::
def enumerate(sequence, start=0):
n = start
Expand Down Expand Up @@ -640,7 +642,12 @@ def issubclass(cls: _type, classinfo: Union[_type, Tuple[_type]]) -> _bool:

def iter(object: Union[Iterable, Sequence]) -> Iterator:
"""
Returns an iterator object.
iter(object) -> Iterator
Gets the iterator of the object if available.
Arguments:
object: Object for which to get the iterator.
"""


Expand Down Expand Up @@ -691,8 +698,19 @@ def locals() -> _dict:

def map(function: Callable, iterable: Iterable, *args: Any) -> Iterator:
"""
Returns an iterator that applies function to every item of iterable,
yielding the results.
map(function, iterable) -> Iterator
map(function, iterable1, iterable2...) -> Iterator
Creates a new iterator that applies the given function to each item in the
given iterable and yields the results.
Arguments:
function (callable): Function that computes a result for one item in the
iterable(s). The number of arguments to this function must match
the number of iterables given.
iterable (iter): One or more source interables from which to draw data.
With multiple iterables, the iterator stops when the shortest
iterable is exhausted.
"""


Expand Down

0 comments on commit 84d1d7b

Please sign in to comment.