Python dedicated class for file names
<p>I am writing a program that utilises a large number of files. Does Python feature an inbuilt class for file paths, or does one have to be implemented by the user (like below):</p>

<pre><code>class FilePath:
    def __init__(path):
        shazam(path)

    def shazam(self, path):
        """ something happens, path is formatted, etc """
        self.formatted_path = foobar
</code></pre>

<p><strong>Why would it be useful?</strong></p>

<p>Suppose the program and its data is copied to a different operating system. The class could modify itself on launch to support the a different path separator.</p>

<p><strong>Why not just write it yourself?</strong></p>

<p>Someone might have already written a class in the standard Python library.</p>

<p>Since Python 3.4 there is <a href="https://docs.python.org/3/library/pathlib.html" rel="nofollow">pathlib</a> which seems to be what you are looking for. Of course there are the functions from <a href="https://docs.python.org/3/library/os.path.html" rel="nofollow">os.path</a>, too - but for an object-oriented approach pathlib is fitting better.</p>

python file class variables