[Python-Dev] Further PEP 8 compliance issues in threading and multiprocessing
Steven D'Aprano
steve at pearwood.info
Tue Sep 2 18:36:41 CEST 2008
On Mon, 1 Sep 2008 11:24:02 pm Nick Coghlan wrote:
> I've been taking a close look at the API for multiprocessing and
> threading, and have discovered a somewhat strange pattern that occurs
> multiple times in both interfaces: factory functions with names that
> start with a capital letter so they look like they're actually a
> class.
>
> At first I thought it was a quirk of the multiprocessing
> implementation, but then I discovered that the threading module also
> does it for all of the synchronisation objects as well as
> threading.Timer, with examples like:
>
> def Event(*args, **kwds):
> return _Event(*args, **kwds)
Can anyone explain why those factory functions exist at all? They don't
seem to do anything. Why not expose the class directly, instead of
making it private and then exposing it via a factory function that does
nothing else? Never mind whether or not the factory functions should
start with an uppercase letter or not. Why are they even there?
Perhaps I'm missing some subtle (or even not-so-subtle) advantage, but
it seems rather silly to me, as silly as this:
f = lambda x: function(x)
# better written as f = function
And yet threading.py has at least six examples just like that. What am I
missing?
--
Steven
More information about the Python-Dev
mailing list