type annotation vs working code
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Oct 4 02:44:19 EDT 2023
On 4/10/23 5:25 pm, dn wrote:
> The first question when dealing with the Singleton Pattern is what to do
> when more than one instantiation is attempted
My preferred way of handling singletons is not to expose the class
itself, but a function that creates an instance the first time it's
called, and returns that instance subsequently. The problem then
doesn't arise.
--
Greg
More information about the Python-list
mailing list