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

Weakref proxy is for instance only ...

To speed up accessing files on nfs shares on a ubuntu machine ...