I need to pass an extension to function, and then have that function pull all files with that extension in both lower and uppercase form.
For example, if I passed mov, I need to function to do:
videos = [file for file in glob.glob(os.path.join(dir, '*.[mM][oO][vV]'))]
How would I accomplish the lower + upper combination above given a lowercase input?
Something like this?
>>> def foo(extension):
... return '*.' + ''.join('[%s%s]' % (e.lower(), e.upper()) for e in extension)
...
>>> foo('mov')
'*.[mM][oO][vV]'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With