singleton ... again

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Feb 14 06:21:40 CET 2014


Ethan Furman 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).

No, you shouldn't ask for SerialPort(2) at all, you should
call get_serial_port(2). Then you won't be fooled into
thinking that you're creating an independent object each
time.

-- 
Greg



More information about the Python-list mailing list