Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95843

Re: Low level file descriptors and high-level Python files

Path csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <lac@openend.se>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'bits': 0.07; 'pretend': 0.07; 'subject:file': 0.07; 'cc:addr :python-list': 0.09; 'descriptor': 0.09; 'mode,': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'sake': 0.09; 'subject:files': 0.09; 'way:': 0.09; 'wed,': 0.15; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'message-id:@fido.openend.se': 0.16; 'posix': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'with?': 0.16; 'else,': 0.18; 'laura': 0.18; 'passes': 0.18; '2015': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'are.': 0.22; 'sep': 0.22; 'suppose': 0.22; 'somewhere': 0.24; 'discussion': 0.24; 'received:se': 0.29; 'cc:no real name:2**1': 0.29; "i'm": 0.30; 'somebody': 0.30; 'windows.': 0.33; 'file': 0.34; 'could': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'closing': 0.36; 'mode': 0.36; 'subject:: ': 0.37; 'charset :us-ascii': 0.37; 'things': 0.38; 'subject:-': 0.39; 'some': 0.40; 'header:Message-Id:1': 0.61; 'details': 0.62; 'yourself': 0.73; '+1000,': 0.84; 'header:In-reply-to:1': 0.84
To "Steven D'Aprano" <steve@pearwood.info>
cc python-list@python.org, lac@openend.se
From Laura Creighton <lac@openend.se>
Subject Re: Low level file descriptors and high-level Python files
In-reply-to <55e5bcd3$0$1639$c3e8da3$5496439d@news.astraweb.com>
References <55e5bcd3$0$1639$c3e8da3$5496439d@news.astraweb.com>
Comments In-reply-to "Steven D'Aprano" <steve@pearwood.info> message dated "Wed, 02 Sep 2015 00:57:22 +1000."
MIME-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-ID <19126.1441129302.1@fido>
Date Tue, 01 Sep 2015 19:41:42 +0200
X-Greylist Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [89.233.217.130]); Tue, 01 Sep 2015 19:41:49 +0200 (CEST)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.53.1441129318.23514.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1441129318 news.xs4all.nl 23869 [2001:888:2000:d::a6]:39802
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:95843

Show key headers only | View raw


In a message of Wed, 02 Sep 2015 00:57:22 +1000, "Steven D'Aprano" writes:
>Let's suppose somebody passes me a file descriptor to work with. It could
>come from somewhere else, but for the sake of discussion let's pretend I
>create it myself this way:

>Q1:  In this example, I know that I opened the fd in write mode, because I
>did it myself. But since I'm not actually opening it, how do I know what
>mode to use in the call to fdopen? Is there something I can call to find
>out what mode a file descriptor has been opened with?

for POSIX things use fnclt.  YOu have to parese the bits yourself
and I always have to look that up to see what the grubby details
are.  No clue what you do on windows.

Don't go around closing things you don't know are open.  They
could be some other processes' thing.

Laura

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Low level file descriptors and high-level Python files Steven D'Aprano <steve@pearwood.info> - 2015-09-02 00:57 +1000
  Re: Low level file descriptors and high-level Python files random832@fastmail.us - 2015-09-01 11:56 -0400
  Re: Low level file descriptors and high-level Python files Laura Creighton <lac@openend.se> - 2015-09-01 19:41 +0200
    Re: Low level file descriptors and high-level Python files Grant Edwards <invalid@invalid.invalid> - 2015-09-01 22:19 +0000
      Re: Low level file descriptors and high-level Python files Laura Creighton <lac@openend.se> - 2015-09-02 09:02 +0200

csiph-web