AutoInitAndCloseable

class tfsnippet.utils.AutoInitAndCloseable

Bases: object

Classes with init() to initialize its internal states, and also close() to destroy these states. The init() method can be repeatedly called, which will cause initialization only at the first call. Thus other methods may always call init() at beginning, which can bring auto-initialization to the class.

A context manager is implemented: init() is explicitly called when entering the context, while destroy() is called when exiting the context.

Methods Summary

close() Ensure the internal states are destroyed.
init() Ensure the internal states are initialized.

Methods Documentation

close()

Ensure the internal states are destroyed.

init()

Ensure the internal states are initialized.