decorateme._behavior
Decorators that affect object or class behavior.
Module Contents
Functions
|
Prints a statement like "Call to calc_distances took 15.2s." after the function returns. |
|
Prints a statement like "Done. Took 15.2s." after the function returns. |
|
Just marks an object as mutable. |
|
Decorator for making a slot-based class immutable. |
|
Makes it so the constructor returns a singleton instance. |
- decorateme._behavior.takes_seconds_named(x, *args, **kwargs)
Prints a statement like “Call to calc_distances took 15.2s.” after the function returns.
- decorateme._behavior.takes_seconds(x, *args, **kwargs)
Prints a statement like “Done. Took 15.2s.” after the function returns.
- decorateme._behavior.mutable(cls)
Just marks an object as mutable.
- decorateme._behavior.immutable(mutableclass)
Decorator for making a slot-based class immutable. Taken almost verbatim from https://code.activestate.com/recipes/578233-immutable-class-decorator/ Written by Oren Tirosh and released under the MIT license.
- decorateme._behavior.auto_singleton(cls)
Makes it so the constructor returns a singleton instance. The constructor CANNOT take arguments.
Example
@auto_singleton class MyClass: pass mysingleton = MyClass()