On Jun 21, 2013, at 8:05 AM, [email protected] wrote:

> Hello,
> 
> I've noticed there are a couple public APIs in Twisted now that accept a 
> "private" positional argument.  I use scare quotes because I don't see how 
> it's actually possible to make a positional argument private.
> 
> Given a function defined like this:
> 
>   def foo(_bar=None):
>       ...
> 
> There is no indication that a use like this is problematic:
> 
>   foo(3)
> 
> Perhaps the situation will be different with keyword-only arguments, but for 
> positional arguments I think it's unproductive and perhaps even confusing to 
> name arguments this way.
> 
> I suggest we fix the couple places where this has been done so far and we 
> avoid introducing any new instances.
> 
> FWIW, I found two examples of this in Twisted using:
> 
>   $ grep -E '\W_reactor' twisted/ -r --include '*.py' | grep -E 'def\W'

I second this suggestion.

Furthermore, in most cases where one is tempted to make a reactor *attribute* 
private, it's probably best to make it public.  There are lots of legitimate 
uses to parameterize the reactor and to discover which one a particular object 
is using.

The case where one is tempted to make an argument private like this seems to be 
somewhere that we feel that something should be parameterized "only for 
testing".  If we need to parameterize it for testing, our users probably need 
to parameterize it for *their* tests, too.

-glyph

_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to