os.path.splitext() and case sensitivity
Richie Hindle
richie at entrian.com
Wed Dec 21 08:36:11 EST 2005
[rbt]
> Is there a way to make os.path.splitext() case agnostic?
>
> def remove_file_type(target_dir, file_type):
> for root, dirs, files in os.walk(target_dir):
> for f in files:
> if os.path.splitext(os.path.join(root, f))[1] in file_type:
> pass
>
> remove_file_type(sysroot, ['.tmp', '.TMP'])
def remove_file_type(target_dir, file_type):
[...]
if os.path.splitext(f)[1].lower() == file_type.lower():
pass
remove_file_type(sysroot, '.tmp')
--
Richie Hindle
richie at entrian.com
More information about the Python-list
mailing list