Inquiry regarding the name of subprocess.Popen class

Derek Martin code at pizzashack.org
Tue Sep 2 19:54:12 EDT 2008


On Tue, Sep 02, 2008 at 10:55:54PM +0000, Marc 'BlackJack' Rintsch wrote:
> On Tue, 02 Sep 2008 18:15:07 -0400, Derek Martin wrote:
> 
> >> Classes represent "things", and class names should be nouns.
> > 
> > Is that a law?
> 
> It's a common guideline.

Right.  It's a guideline.

> > Classes are instantiated by invoking their class names as a function
> > call -- the computing equivalent of a verb.  Why then, must they be
> > named as nouns?  Can you not, in fact, have classes which describe (or
> > model) actions?  Wouldn't you name them using verbs if you did?
> 
> Me personally no.  I would use `FooAction` instead of `Foo` or something 
> similar.  

Maybe you would, but I think a lot of folks would just use the action
name (i.e. the verb).

> And if they model an action there must be some way to activate 
> the action 

That's a reasonable assumption, but as I also said, the object might
just describe the action -- essentially the equivalent of a struct in
C.

> but the instances of `Popen` are no actions.  There's no way to
> "execute" a `Popen` instance.

Yes there is... you execute it when you instantiate the object.  At
the time of instantiation, you "open" the "P" (pipes).  For an object
which describes an action, I think it's perfectly sensible that
instantiation is when the action occurs, though there could be other
times (e.g. if the object had an "execute" method) which make as much
sense.

> > My point is, if you don't think Popen is a good name for the class,
> > that's your opinion, but it is only that: an opinion.
> 
> Like your opinion that it *is* a good name.

Yes, exactly.

> > Yet some of you state your case as if it is incontrovertable fact. 
> > I've given a good case as to why it IS a good name (one which I
> > genuinely support), and disagree as you may, none of the points any of
> > you have made invalidate or even weaken my argument.
> 
> Maybe from your POV.  Facts:  It doesn't use the `popen()` function

So?  Neither does the C version of popen(), but that function is still
called popen()! :-D  As I've already said a few times now, it is
conceptually based on popen().  The fact that it doesn't use popen()
is not interesting; it (or the portion of it that corresponds to what
popen() does) is implemented almost exactly the same way as the
C popen() function (except in Python, rather than C).  That, to me, is
much more interesting.  pclose() does what Popen.wait() does,
essentially.  Sure, the class has a few extre bells and whistles that
the C implementation doesn't have, but:

> it gives something more complex than a simple pipe 

Gosh, one would hope that it would be universally true that an
object-oriented implementation of something that was originally
designed using conventional programming techniques would provide more
than one piece of the conventional implementation...  We might even
hope that it would improve upon 40-year-old implementations, wherever
possible...

> to three file objects, more attributes and methods), the function used on 
> Windows under the hood is called `CreateProcess()` not `CreatePipe()`.  

How does Windows implement popen()?  [I think they call it _popen()
though...]

> `Popen` creates a process and represents a proxy object to communicate 
> with it, so `Process` is a good name for that concept/"thing".  

I disagree; the point of that process creation is the communication
between the two processes.  Calling it a process does not reflect this
very important aspect of the object.  The Popen object is not a
process; it is a collection of pipes and methods used to communicate
with one.

> It's a way more self explaining name, even for people who know the
> `popen()` function 

I, and apparently the maintainers (at least at the time they added
this thing) don't agree.  In fact I think it's quite the opposite.  If
I came across such a "process" object without knowing what it was, I
would expect that a process object described a running process, i.e.
gave information about things like executable path name, cpu and
memory utilization, perhaps a list of all open file descriptors (but
not just three specific ones), etc; or something similar.  This object
provides none of that.  It does not, in fact, describe a process at
all.  It is quite distinct and different from the concept of a
process, indeed.

> because there's a concept called "process" but none called "popen".

Anything that exists can be conceptualized and therefore is a concept.
The popen concept exists, and is more than just a concept; it has a
concrete implementation in C AND Python and numerous other languages.
Verbs can be concepts too.

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20080902/fdbb0f86/attachment.sig>


More information about the Python-list mailing list