[Python-Dev] IO module improvements (original) (raw)

Guido van Rossum guido at python.org
Fri Feb 5 19:38:12 CET 2010


On Fri, Feb 5, 2010 at 8:46 AM, <exarkun at twistedmatrix.com> wrote:

On 03:57 pm, guido at python.org wrote:

On Fri, Feb 5, 2010 at 5:28 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:

Pascal Chambon <pythoniks gmail.com> writes:

By the way, I'm having trouble with the "name" attribute of raw files, which can be string or integer (confusing), ambiguous if containing a relative path, Why is it ambiguous? It sounds like you're using str() of the name and then can't tell whether the file is named e.g. '1' or whether it refers to file descriptor 1 (i.e. sys.stdout). I think string/integer and ambiguity were different points.  Here's the ambiguity: exarkun at boson:~$ python Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)    [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os, io >>> f = io.open('.bashrc') >>> os.chdir('/') >>> f.name '.bashrc' >>> os.path.abspath(f.name) '/.bashrc' >>> Jean-Paul

You're right, I didn't see the OP's comma. :-)

I don't think this can be helped though -- I really don't want open() to be slowed down or complicated by an attempt to do path manipulation. If this matters to the app author they should use os.path.abspath() or os.path.realpath() or whatever before calling open().

-- --Guido van Rossum (python.org/~guido)



More information about the Python-Dev mailing list