On 2015-05-21 17:31, Grant Edwards wrote:
On 2015-05-21, Chris Angelico <ros...@gmail.com> wrote:
On Fri, May 22, 2015 at 12:14 AM, Grant Edwards <invalid@invalid.invalid> wrote:
On 2015-05-21, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote:

import glob
print(glob.glob("c:/abc/def/ghjmain/features/XYZ/*<filename>"))

Don't use backslashes \ as they have special meaning to Python. Use forward
slashes and let Python convert them as needed.

Interesting. I've never heard about this.

When will Python convert them?

Actually, it won't ever bother to convert them.

OK, so this isn't some new feature I hadn't heard about due to my
spending most of my time with 2.7. :)

The Windows file system APIs are quite happy to work with forward
slashes;

Yep, I knew that -- I have always use forward slashes on Windows (and
DOS before that) when dealing with the file system.

it's only command-line tools (which conventionally use forward
slashes to introduce options), and not all of them, which require
backslashes.

Dialog boxes, however, insist on backslashses.

Yup, I was wondering if that was where Python (or its stdlib) would
convert them (which would have surprised me).  Back in the day, you
could change the 'option switch' character from '/' to whatever you
wanted (and as an old Unix guy, I always set it to '-').  Then you
could even use forward slashes on the command line (mostly). But, I
don't think Windows has support that for yonks.


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to