Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'value,': 0.04; 'plenty': 0.07; 'think,': 0.07; 'apis': 0.09; 'executable': 0.09; 'api': 0.11; 'systems.': 0.12; 'andr\xe9': 0.16; 'descriptors,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'example': 0.22; 'certainly': 0.24; 'example.': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'room': 0.29; 'needed.': 0.30; 'said,': 0.30; 'especially': 0.30; 'message- id:@mail.gmail.com': 0.30; 'file': 0.32; 'another': 0.32; 'quite': 0.32; 'running': 0.33; 'sense': 0.34; 'etc': 0.35; 'received:google.com': 0.35; 'starting': 0.37; 'implement': 0.38; 'to:addr:python-list': 0.38; '12,': 0.39; 'bad': 0.39; 'itself': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'new': 0.61; 'simple': 0.61; 'details': 0.65; 'limits,': 0.84; 'subject:skip:o 10': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=J1vpAeqTmo/4fzM+1tPUpAVTUnzdJQrAiH5dyDEhnV0=; b=UxOIRFrOyr6ZKeS9UCTBs2II8u9NhTRWmBZE01wS98+CvlBPJBhcQR6GBIsYPSjzYu 1Ahv9ialGlQU9tJwYPYJs1RuIzp8PCHFLextIo7oHPW84jqTmEJWFrP3xEbDRHbjjds2 83PSMK3Qd3sMAGsx8RGhK5RZ8C9FRh6bF+OaHQoMEY0Rj4Pd8YXKS2MofHC9D1MxEzqH qIBH17r8pNjkylktaFLX7n/KyiWMIfnblReEFabACHLmxRkP/OL22O3JSK2Z+0NKq91o SQJfLv4nFZ8NxPTrSPMmOxGeECFKkYjGas8jkmu/xfZ4jexNfd9Hrk0RlZm8UlSDFKbb EnOQ== MIME-Version: 1.0 X-Received: by 10.58.226.163 with SMTP id rt3mr14010266vec.55.1368288290296; Sat, 11 May 2013 09:04:50 -0700 (PDT) In-Reply-To: <2048586.oD9bP8C7rC@news.perlig.de> References: <518a123c$0$11094$c3e8da3@news.astraweb.com> <518b32ef$0$11120$c3e8da3@news.astraweb.com> <518be931$0$29997$c3e8da3$5496439d@news.astraweb.com> <518c5bbc$0$29997$c3e8da3$5496439d@news.astraweb.com> <518c7f8e$0$29997$c3e8da3$5496439d@news.astraweb.com> <518cd360$0$29997$c3e8da3$5496439d@news.astraweb.com> <2048586.oD9bP8C7rC@news.perlig.de> Date: Sun, 12 May 2013 02:04:50 +1000 Subject: Re: object.enable() anti-pattern From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368288293 news.xs4all.nl 15888 [2001:888:2000:d::a6]:39754 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45144 On Sun, May 12, 2013 at 1:33 AM, Andr=E9 Malo wrote: > * Serhiy Storchaka wrote: > >> Another example is running a subprocess in Unix-like systems. >> >> fork() >> open/close file descriptors, set limits, etc >> exec*() > > For running a subprocess, only fork() is needed. For starting another > executable, only exec() is needed. For running the new executable in a > subprocess fork() and exec() are needed. I think, that's a bad example. > These APIs are actually well-designed. That said, though, there's certainly plenty of room for one-call APIs like popen. For the simple case where you want to start a process with some other executable, wait for it to finish, and then work with its return value, it makes sense to hide the details of fork/exec/wait - especially since that simple API can be cross-platform, where fork() itself is quite hard to implement on Windows. ChrisA