mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 01:24:17 +00:00
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:
+19
-18
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user