singleton ... again

Roy Smith roy at
Thu Feb 13 18:57:43 CET 2014

In article <mailman.6850.1392313443.18130.python-list at>,
 Ethan Furman <ethan at> wrote:

> Say you have a class that represents serial ports or your computer.  You 
> should get the same object every time you ask 
> for SerialPort(2).

Why?  Certainly, you should get objects which refer to the same physical 
port.  So:

port_a = SerialPort(2)
port_b = SerialPort(2)

assert port_b.is_shutdown() == False

assert port_b.is_shutdown() == True

But, why do they have to be the same object?  Why should I care if

port_a is port_b

is False, as long as all operations I perform on either are reflected in 
correct state changes on the other one?

More information about the Python-list mailing list