Best way to ensure user calls methods in correct order?

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Jun 23 01:44:05 EDT 2017


Steve D'Aprano wrote:
> There are a very few exceptions to this rule of thumb, such as opening
> connections to databases or files or similar.

Another way to handle that is to have the connection method
return another object that has the methods that should only
be called for active connections. That way it's not possible
to do things out of sequence.

-- 
Greg



More information about the Python-list mailing list