which is the right file path format in python3.4 ?

Chris Angelico rosuav at gmail.com
Sun Dec 14 07:13:12 EST 2014


On Sun, Dec 14, 2014 at 10:51 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> I don't have access to a Windows box to check, otherwise I would do it
> myself. What happens if you specify a non-existent drive letter?
>
> open("Q:\\xxx")  # Assuming you don't have a drive Q.

Hmm. I just grabbed one (granted, it's XP not W7) and checked it, and
it's not what I was expecting either.

Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:24:06) [MSC v.1600
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> open("Q:\\xxx")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'Q:\\xxx'

Still, it might be something unusual about the OP's drive. Maybe a
network drive with a broken connection, or a mounted CD, or an alias
for another directory... who knows. Hopefully the stat and access
checks will reveal something.

ChrisA



More information about the Python-list mailing list