Constants and Helpers
Parameters:obj – Object to proxy to.
Bind the proxy to the given object. Afterwards all attribute lookupsand method calls on the proxy will be sent to the given object.
Any callbacks that have been registered will be called.
Parameters:callback – A function that accepts a single parameter, the boundobject.Returns:self
Add a callback to be executed when the proxy is initialized.
- class
DatabaseProxy
- Proxy subclass that is suitable to use as a placeholder for a
Database
instance.
See Dynamically defining a database for details on usage.
Parameters:
- iterable – an iterable that is the source of the data to be chunked.
- n (int) – chunk sizeReturns:a new iterable that yields n-length chunks of the source data.
Efficient implementation for breaking up large lists of data intosmaller-sized chunks.
Usage:
- it = range(10) # An iterable that yields 0...9.
- # Break the iterable into chunks of length 4.
- for chunk in chunked(it, 4):
- print(', '.join(str(num) for num in chunk))
- # PRINTS:
- # 0, 1, 2, 3
- # 4, 5, 6, 7
- # 8, 9