| Home | Trees | Indices | Help |
|
|---|
|
|
object --+
|
stacker
A mixin that accumulates options and provides a factory for instances of the same class.
stacker saves the list of arguments and the dictionairy of keywords. It also offers a callable interface that acts as af factory of new instance of a a class. When called it combines all stored arguments and keywords with additional ones. This facilitates the following pattern:
RefToMyObjectInstance -option | ...
Here option is a reference to an instance of the class option. What happens in this example is this (pseudocode):
RefToMyObjectInstance = MyObject(option1=value)
RefToMyObjectInstance -option | ...
RefToMyObjectInstance.__sub__(option2)
calls:
RefToMyObjectInstance.__cal__(options2.name=option2.value)
results in:
an (anonymous) object of the same class as RefToMyObjectInstance with
both options (option1 and option2) set.
|
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
|
|||
|
Inherited from |
|||
|
|||
Facilitates using a instance as a factory for the class it belongs to. This way we can create an instance of a class with the same name as a class to be used as a shortcut when calling without arguments while creating seperate anonimous instances when calling with arguments. Example: for a class 'ls' we can now do this in Command.py: ls=ls() This way we can now write the following: from Command import * ls | sort > stdout while we can still write:
ls('*.txt') | sort(reverse=true) > stdout
extra arguments and options are accumlated which allows us to write (with the help of the __sub__ operator defined in the stacker class:
...| grep('aaa') -i -v | ...
here we create a grep instance and then a new grep instance is created with the -i (i.e. the __sub__ method on the grep instance is called with the predefined i (and instance of the option class).) |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sat Jun 20 16:07:45 2009 | http://epydoc.sourceforge.net |