I'm trying to design a class to manage video devices in Linux (/dev/video*).
Because of my C++ background I naturally thought I could open the file in the constructor and close it in the destructor.
Then later I learned python does not guarantee when/if the destructor is called.
Then I think I can make my own "initialize" and "de-initialize" methods to manage the opening/closing of the device file, but then it creates time gaps when the objected is constructed but not initialized and also when the object is de-initialized but not destructed, at which time the object does not have a valid internal state ( the methods are mostly ioctls on the opened video device).
That means I need to validate object state at the beginning of each method , like built-in file objects (f=open(), f.close)? Or just let the I/O error occur when a method is called on an already de-initialized object?