本文整理汇总了Python中__builtin__.map方法的典型用法代码示例。如果您正苦于以下问题:Python __builtin__.map方法的具体用法?Python __builtin__.map怎么用?Python __builtin__.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类__builtin__
的用法示例。
在下文中一共展示了__builtin__.map方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_instance_factory
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import map [as 别名]
def is_instance_factory(_type):
"""
Parameters
----------
`_type` - the type to be checked against
Returns
-------
validator - a function of a single argument x , which raises
ValueError if x is not an instance of `_type`
"""
if isinstance(_type, (tuple, list)):
_type = tuple(_type)
type_repr = "|".join(map(lambda x: x.__name__, _type))
else:
type_repr = "'{typ}'".format(typ=_type.__name__)
def inner(x):
if not isinstance(x, _type):
msg = "Value must be an instance of {type_repr}"
raise ValueError(msg.format(type_repr=type_repr))
return inner
示例2: lmap
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import map [as 别名]
def lmap(*args, **kwargs):
return list(map(*args, **kwargs))
示例3: flatmap
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import map [as 别名]
def flatmap(f, items):
return chain.from_iterable(map(f, items))
示例4: __repr__
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import map [as 别名]
def __repr__(self):
if not self:
return '%s()' % self.__class__.__name__
items = ', '.join(map('%r: %r'.__mod__, self.most_common()))
return '%s({%s})' % (self.__class__.__name__, items)
# Multiset-style mathematical operations discussed in:
# Knuth TAOCP Volume II section 4.6.3 exercise 19
# and at http://en.wikipedia.org/wiki/Multiset
#
# Outputs guaranteed to only include positive counts.
#
# To strip negative and zero counts, add-in an empty counter:
# c += Counter()
示例5: __new__
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import map [as 别名]
def __new__(cls, function, *iterables):
new_map = _coconut.map.__new__(cls, function, *iterables)
new_map.func = function
new_map.iters = iterables
return new_map
示例6: __repr__
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import map [as 别名]
def __repr__(self):
return "map(%r, %s)" % (self.func, ", ".join((_coconut.repr(i) for i in self.iters)))
示例7: __copy__
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import map [as 别名]
def __copy__(self):
return self.__class__(self.func, *_coconut.map(_coconut.copy.copy, self.iters))
示例8: __iter__
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import map [as 别名]
def __iter__(self):
from concurrent.futures import ProcessPoolExecutor
with ProcessPoolExecutor() as executor:
return _coconut.iter(_coconut.list(executor.map(self.func, *self.iters)))