kopia lustrzana https://github.com/micropython/micropython-lib
functools: Implement partial().
rodzic
d3761c3896
commit
7b02354bd1
|
@ -0,0 +1,6 @@
|
|||
def partial(func, *args, **kwargs):
|
||||
def _partial(*more_args, **more_kwargs):
|
||||
kw = kwargs.copy()
|
||||
kw.update(more_kwargs)
|
||||
func(*(args + more_args), **kw)
|
||||
return _partial
|
|
@ -0,0 +1,3 @@
|
|||
srctype = micropython-lib
|
||||
type = module
|
||||
version = 0.0.1
|
|
@ -1,18 +1,18 @@
|
|||
import sys
|
||||
# Remove current dir from sys.path, otherwise distutils will peek up our
|
||||
# module instead of system one.
|
||||
# Remove current dir from sys.path, otherwise setuptools will peek up our
|
||||
# module instead of system.
|
||||
sys.path.pop(0)
|
||||
sys.path.insert(0, '..')
|
||||
from setuptools import setup
|
||||
import metadata
|
||||
|
||||
NAME = 'functools'
|
||||
|
||||
setup(name='micropython-' + NAME,
|
||||
version='0.0.0',
|
||||
description=metadata.desc_dummy(NAME),
|
||||
url=metadata.url,
|
||||
author=metadata.author_upy_devels,
|
||||
author_email=metadata.author_upy_devels_email,
|
||||
setup(name='micropython-functools',
|
||||
version='0.0.1',
|
||||
description='functools module for MicroPython',
|
||||
long_description="This is a module reimplemented specifically for MicroPython standard library,\nwith efficient and lean design in mind. Note that this module is likely work\nin progress and likely supports just a subset of CPython's corresponding\nmodule. Please help with the development if you are interested in this\nmodule.",
|
||||
url='https://github.com/micropython/micropython/issues/405',
|
||||
author='MicroPython Developers',
|
||||
author_email='micro-python@googlegroups.com',
|
||||
maintainer='MicroPython Developers',
|
||||
maintainer_email='micro-python@googlegroups.com',
|
||||
license='MIT',
|
||||
py_modules=[NAME])
|
||||
py_modules=['functools'])
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
from functools import partial
|
||||
|
||||
def foo(x, y, prompt="result:"):
|
||||
print(prompt, x + y)
|
||||
|
||||
|
||||
f = partial(foo, 10, prompt="arg+10:")
|
||||
f(20)
|
Ładowanie…
Reference in New Issue