Created
September 21, 2020 00:50
-
-
Save NoahCardoza/bce83cd899175e9dfa90b13744c06454 to your computer and use it in GitHub Desktop.
Python: split_path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: [email protected] | |
from os import path | |
def split_path(location): | |
"""splits the path into a tuple of all it's parts using recursion""" | |
head, tail = path.split(location) | |
if tail: | |
return split_path(head) + (tail,) | |
if head: | |
return (head,) | |
return tuple() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment