Class Hamster
source code
Simple container class with basic IO capabilities.
It is capable of storing itself in a file, or loading from a file using
cPickle (optionally via zlib from compressed files). Any serializable
object can be bound to a hamster to be stored.
To undig burried hamster use Hamster(filename). Here is an example:
>>> h = Hamster(bla='blai')
>>> h.boo = N.arange(5)
>>> h.dump(filename)
...
>>> h = Hamster(filename)
Since Hamster introduces methods dump, asdict and property
'registered', those names cannot be used to assign an attribute,
nor provided in among constructor arguments.
|
__new__(cls,
*args,
**kwargs)
Returns:
a new object with type S, a subtype of T |
source code
|
|
|
|
|
dump(self,
filename,
compresslevel='auto')
Bury the hamster into the file |
source code
|
|
|
|
|
|
|
|
|
asdict(self)
Return registered data as dictionary |
source code
|
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__reduce__ ,
__reduce_ex__ ,
__str__
|
|
__ro_attr = set(object.__dict__.keys()+ ['dump', 'registered',...
Attributes which come with being an object
|
Inherited from object :
__class__
|
- Returns:
a new object with type S, a subtype of T
- Overrides:
object.__new__
- (inherited documentation)
|
__init__(self,
*args,
**kwargs)
(Constructor)
| source code
|
Initialize Hamster.
Providing a single parameter string would treat it as a
filename from which to undig the data. Otherwise all keyword
parameters are assigned into the attributes of the object.
- Overrides:
object.__init__
|
repr(x)
- Overrides:
object.__repr__
- (inherited documentation)
|
List registered attributes.
- Decorators:
|
Just to prevent resetting read-only attributes, such as methods
- Overrides:
object.__setattr__
|
__ro_attr
Attributes which come with being an object
- Value:
set(object.__dict__.keys()+ ['dump', 'registered', 'asdict'])
|
|