Strange factory pattern

Zac Burns zac256 at gmail.com
Tue Jun 22 22:33:55 EDT 2010


In the threading module there are several code bits following this
convention:

###
def Class(*args, **kwargs):
    return _Class(*args, **kwargs)

class _Class(...
###

This is true for Event, RLock, and others.

Why do this? It seems to violate the rule of least astonishment
(isinstance(Event(), Event) raises an exception). I assume there must be
some trade-off that the designer intended to achieve. So, what is that
trade-off and when should I follow this in my code?

--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer
Zindagi Games
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100622/d6d49320/attachment.html>


More information about the Python-list mailing list