Splitting python path using os.path module

Avoid using "/" at the end of the directory paths as they would generate empty filename when used with functions like os.path.split()

>>> import os
>>> os.path.split('/tmp/foo')
('/tmp', 'foo')
>>> os.path.split('/tmp/foo/')
('/tmp/foo', '')


Reference: https://docs.python.org/2/library/os.path.html

Comments

Popular posts from this blog

Multiple repeat error when the regex has multiple wildcards in python re module

Avoid using global/class-level mutable datatypes like list/dicts

Weakref proxy is for instance only ...