Coverage for /home/kale/hacking/libraries/nonstdlib/nonstdlib/meta.py : 97%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/env python
else: function.func_defaults = deepcopy(defaults)
""" Decorator function that turns a class into a singleton. """
# Create a structure to store instances of any singletons that get # created.
# Make sure that the constructor for this class doesn't take any # arguments. Since singletons can only be instantiated once, it doesn't # make any sense for the constructor to take arguments. If the class # doesn't implement its own constructor, don't do anything. This case is # considered specially because it causes a TypeError in python 3.3 but not # in python 3.4.
""" Creates and returns the singleton object. This function is what gets returned by this decorator. """
# Check to see if an instance of this class has already been # instantiated. If it hasn't, create one. The `instances` structure # is technically a global variable, so it will be preserved between # calls to this function.
# Return a previously instantiated object of the requested type.
# Return the decorator function.
|