Class | MutableChain |
Thin wrapper around itertools.chain, allowing to add iterables "in-place" |
Class | WeakKeyCache |
Undocumented |
Function | _getargspec_py23 |
_getargspec_py23(function) -> named tuple ArgSpec(args, varargs, keywords, defaults) |
Function | binary_is_text |
Returns True if the given data argument (a bytes object) does not contain unprintable control characters. |
Function | equal_attributes |
Compare two objects attributes |
Function | flatten |
flatten(sequence) -> list |
Function | garbage_collect |
Undocumented |
Function | get_func_args |
Return the argument name list of a callable |
Function | get_spec |
No summary |
Function | global_object_name |
Return full name of a global object. |
Function | iflatten |
iflatten(sequence) -> iterator |
Function | is_listlike |
No summary |
Function | memoizemethod_noargs |
Decorator to cache the result of a method (without arguments) using a weak reference to its object |
Function | re_rsearch |
No summary |
Function | retry_on_eintr |
Run a function and retry it while getting EINTR errors |
Function | to_bytes |
Return the binary representation of text. If text is already a bytes object, return it as-is. |
Function | to_native_str |
Return str representation of text. |
Function | to_unicode |
Return the unicode representation of a bytes object text. If text is already an unicode object, return it as-is. |
Function | unique |
efficient function to uniquify a list preserving item order |
Function | without_none_values |
Return a copy of iterable with all None entries removed. |
Constant | _BINARYCHARS |
Undocumented |
Was identical to inspect.getargspec() in python2, but uses inspect.getfullargspec() for python3 behind the scenes to avoid DeprecationWarning.
>>> def f(a, b=2, *ar, **kw): ... pass
>>> _getargspec_py23(f) ArgSpec(args=['a', 'b'], varargs='ar', keywords='kw', defaults=(2,))
flatten(sequence) -> list
Returns a single, flat list which contains all elements retrieved from the sequence and all recursively contained sub-sequences (iterables).
Examples: >>> [1, 2, [3,4], (5,6)] [1, 2, [3, 4], (5, 6)] >>> flatten([[[1,2,3], (42,None)], [4,5], [6], 7, (8,9,10)]) [1, 2, 3, 42, None, 4, 5, 6, 7, 8, 9, 10] >>> flatten(["foo", "bar"]) ['foo', 'bar'] >>> flatten(["foo", ["baz", 42], "bar"]) ['foo', 'baz', 42, 'bar']
Returns (args, kwargs) tuple for a function >>> import re >>> get_spec(re.match) (['pattern', 'string'], {'flags': 0})
>>> class Test: ... def __call__(self, val): ... pass ... def method(self, val, flags=0): ... pass
>>> get_spec(Test) (['self', 'val'], {})
>>> get_spec(Test.method) (['self', 'val'], {'flags': 0})
>>> get_spec(Test().method) (['self', 'val'], {'flags': 0})
Return full name of a global object.
>>> from scrapy import Request >>> global_object_name(Request) 'scrapy.http.request.Request'
>>> is_listlike("foo") False >>> is_listlike(5) False >>> is_listlike(b"foo") False >>> is_listlike([b"foo"]) True >>> is_listlike((b"foo",)) True >>> is_listlike({}) True >>> is_listlike(set()) True >>> is_listlike((x for x in range(3))) True >>> is_listlike(range(5)) True