ubuiltins: Document enumerate as a function.

Though it is technically its own type in MicroPython, this change follows the CPython documentation. Essentially this just drops the class prefix and leaves everything else unchanged.

This makes more sense when organizing this module by classes and functions. It's also a bit more logical since the equivalent example we provoide is a function definition, not a class definition.
This commit is contained in:
Laurens Valk
2021-07-16 16:07:55 +02:00
parent 29404babcf
commit a0ea0d8ca0
+19 -18
View File
@@ -233,29 +233,30 @@ def divmod(a, b):
"""
class enumerate:
@overload
def __init__(self, iterable: Iterable) -> None:
...
@overload
def enumerate(iterable: Iterable) -> Iterable:
...
@overload
def __init__(self, iterable: Iterable, start: int) -> None:
...
def __init__(self, *args) -> None:
"""
Returns an enumerate object.
@overload
def enumerate(iterable: Iterable, start: int) -> Iterable:
...
Equivalent to::
def enumerate(sequence, start=0):
n = start
for elem in sequence:
yield n, elem
n += 1
def enumerate(*args) -> Iterable:
"""
Returns an enumerate object.
.. note:: This type is not available on the BOOST Move hub.
"""
Equivalent to::
def enumerate(sequence, start=0):
n = start
for elem in sequence:
yield n, elem
n += 1
.. note:: This type is not available on the BOOST Move hub.
"""
@overload