asq.record
¶
Records provide a convenient anonymous class which can be useful for
managing intermediate query results. new()
provides a concise way to
create Records
in the middle of a query.
asq.record.Record
¶
- class
asq.record.
Record
(**kwargs)¶A class to which any attribute can be added at construction.
__init__
(**kwargs)¶Initialise a Record with an attribute for each keyword argument.
The attributes of a Record are mutable and may be read from and written to using regular Python instance attribute syntax.
Parameters: **kwargs – Each keyword argument will be used to initialise an attribute with the same name as the argument and the given value.
__repr__
()¶A valid Python expression string representation of the Record.
__str__
()¶A string representation of the Record.
asq.record.new
¶
asq.record.
new
(**kwargs)¶A convenience factory for creating Records.
Parameters: **kwargs – Each keyword argument will be used to initialise an attribute with the same name as the argument and the given value. Returns: A Record which has a named attribute for each of the keyword arguments. Example
Create an employee and the get and set attributes:
>>> employee = new(age=34, sex='M', name='Joe Bloggs', scores=[3, 2, 9, 8]) >>> employee Record(age=34, scores=[3, 2, 9, 8], name='Joe Bloggs', sex='M') >>> employee.age 34 >>> employee.name 'Joe Bloggs' >>> employee.age = 35 >>> employee.age 35