Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!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.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:command': 0.09; 'subject:module': 0.09; 'subject:using': 0.09; 'andreas': 0.16; 'bye,': 0.16; 'fp:': 0.16; 'letting': 0.16; 'skip:> 20': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'later': 0.20; '>>>': 0.22; 'import': 0.22; 'otherwise,': 0.22; 'creating': 0.23; 'nearly': 0.26; 'permission': 0.26; 'header:In-Reply-To:1': 0.27; 'thus': 0.29; "doesn't": 0.30; 'asked': 0.31; 'convenience': 0.31; 'file': 0.32; 'another': 0.32; 'linux': 0.33; 'subject:with': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'charset:us- ascii': 0.36; 'possible': 0.36; 'to:addr:python-list': 0.38; "couldn't": 0.39; 'itself': 0.39; 'delete': 0.39; 'to:addr:python.org': 0.39; 'skip:n 10': 0.64; 'temporary': 0.65; 'received:178': 0.74; 'persistent': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=AjghgyPETRdgJHLKx0pTvigFJCzGTqI7yJEZ5yEPtus=; b=1I4fh9gjT1MFp30BQVBXt9RH6usd8L1vqOEiXnqlbqrwwf7LdZUtOKwEWmpCnTzzKw QIQOzeY1pqyBzkqLcdZbrWF/H6ET5WdJ3+cXO37RlTPWiSc9f6UTWQLisPROaMz0RmFN PpCOntWini3hpQhIyNcy1c9n12AXabOhxTFRIKOqhV41Qgjhu2Ulmr4dej9fuUbfvIzW Van8cIRqi81cMqv9vnyD/mBUSh+B/zzKTCT7gAiE9YtG++3eRSS+5GmR2cakZTcTaTaj 1Giy3ocH6NeW5moY5I4aIgtTcfNs//MkLWMw6dXzpP0AtwdSZ9qFA8nI1mokxz/nq58P otGw== X-Received: by 10.14.208.199 with SMTP id q47mr12536521eeo.77.1386680392102; Tue, 10 Dec 2013 04:59:52 -0800 (PST) Date: Tue, 10 Dec 2013 13:59:47 +0100 From: Andreas Perstinger To: python-list@python.org Subject: Re: using ffmpeg command line with python's subprocess module In-Reply-To: <6030eab0-17f7-4b7b-b057-d0889031b3d2@googlegroups.com> References: <3104d38f-3fca-43b0-b6a4-b600684f765e@googlegroups.com> <6fb2b162-cf9b-4c1c-bf5f-f14baf5baac4@googlegroups.com> <35c86484-d0dd-4954-adee-cde3a2fd7ac1@googlegroups.com> <20131204103827.6c5332c6@Hof> <60f2e393-658c-4e18-85b1-fc7d0b07ddb4@googlegroups.com> <6030eab0-17f7-4b7b-b057-d0889031b3d2@googlegroups.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386683859 news.xs4all.nl 2878 [2001:888:2000:d::a6]:56661 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61468 iMath wrote: >we don't have permission to use the temporary file while it has not >been closed,but when the file is closed , it will be destroyed by >default(delete=True),but once we set delete=False,then we couldn't >depend on the convenience of letting the temporary file automatically >delete itself after it has been used(then we have to delete it later >by os.remove()) ,thus there is nearly no convenience in creating a >temporary file or a persistent one when using NamedTemporaryFile. In your OP you asked for a platform independent solution thus I don't think it's possible to do what you want if the OS doesn't support opening a file another time while it's still open. Otherwise, on my Linux system this works: >>> import tempfile, subprocess >>> with tempfile.NamedTemporaryFile() as fp: ... fp.write(b"foo\nbar\nbaz\n") ... fp.flush() ... subprocess.call(["cat", fp.name]) ... 12 foo bar baz 0 Bye, Andreas