A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-February/097444.html below:

[Python-Dev] IO module improvements

[Python-Dev] IO module improvements [Python-Dev] IO module improvementsGuido van Rossum guido at python.org
Sat Feb 6 00:51:51 CET 2010
On Fri, Feb 5, 2010 at 3:47 PM, Christian Heimes <lists at cheimes.de> wrote:
> I had the idea to add a property that returns the file name based on the
> file descriptor. However there isn't a plain way to lookup the file
> based on the fd on POSIX OSes. fstat() returns only the inode and
> device. The combination of inode + device references 0 to n files due to
> anonymous files and hard links. On POSIX OSes with a /proc file systems
> it's possible to do a reverse lookup by (ab)using /proc/self/fd/, but
> that's a hack.
>
>>>> import os
>>>> f = open("/etc/passwd")
>>>> fd = f.fileno()
>>>> os.readlink("/proc/self/fds/%i" % fd)
> '/etc/passwd'
>
> On Windows it's possible to get the file name from the handle with
> GetFileInformationByHandleEx().
>
> This doesn't strike me as a feasible options ...

It's good to know about such options, but I really don't like to add
such brittle APIs to the standard I/O objects. So, agreed, this is not
feasible.

-- 
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4