本文整理匯總了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)))