On 18/05/2019 03:14, Richard Damon wrote:

> The same directory, running the same program under Mac OS X, which also
> is a case insensitive file system, 

That is your mistake. Darwin, the core of the MacOS X system
is a version of BSD Unix and like all Unix OS is very much
case sensitive.

Some of the GUI tools in MacOS X may work as if they were case
insensitive (presumably for backwards compatibility to MacOS 9)
but the underlying OS is case sensitive and all the Terminal
type tools and commands, including Python, follow suit.

> Is there an easy was to make glob match files as a case insensitive manner?

Depends on what you mean by easy :-)
You could include both upper and lower case letters in the search:


And you could write a helper function to generate the search strings.

But personally I'd probably just use listdir and compare with
my search string expressed as a regex.

for fname in os.listdir('.'):
    if re.match("aregex", fname)

Another option might be to use fnmatch against the uppercase
version of the name

for fname in os.listdir('.'):
   if fnmatch(pattern, fname.upper())

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:

Reply via email to