Constants and Helpers

  • class Proxy
  • Create a proxy or placeholder for another object.

    • initialize(obj)

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.

  • attachcallback(_callback)

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 aDatabase instance.

See Dynamically defining a database for details on usage.

  • chunked(iterable, n)

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:

  1. it = range(10) # An iterable that yields 0...9.
  2.  
  3. # Break the iterable into chunks of length 4.
  4. for chunk in chunked(it, 4):
  5. print(', '.join(str(num) for num in chunk))
  6.  
  7. # PRINTS:
  8. # 0, 1, 2, 3
  9. # 4, 5, 6, 7
  10. # 8, 9