Title: splitting the root from path in a platform-agnostic way in python
Tags: python;split;path;root
Question: i have a path that describe a folder:

```s = foo/bar/baz
```

and i need to split the root from everything else. I know that i could use:

```s.split('/',1)
```

but this is not platform agnostic. Also it seems that the os.path module doesn't implement this feature, so i'm a bit lost. Writing the function from scratch looks like ridiculous amount of work for the task. 


Here is the accepted answer: You can use the ```os.path.sep``` variable whose value is defined according to the platform in which the module is installed.

```import os
s.split(os.path.sep, 1)
```

Comment for this answer: that's exactly what i was looking for! Thanks ;)
Comment for this answer: I would also add os.path.normpath(s).split(os.path.sep, 1) to get the right path every time, in case you cross-platform some path from Linux to Windows.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:02/03/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><split><path><root>', 'Title': 'splitting the root from path in a platform-agnostic way in python', 'ViewCount': 787, 'id': 54508516, 'user_AboutMe': '', 'user_AccountId': 2125967.0, 'user_DisplayName': 'darkpirate', 'user_Reputation': 694.0, 'user_Views': 64.0, 'user_id': 1888132.0}}