Split path in Python
Question: How I could split this:

    
    
    C:\my_dir\repo\branch
    

to:

    
    
    ['C:\my_dir', rest_part_of_string]
    

where `rest_part_of_string` can be one string or could be splitted every `\`.
I don't care about rest, i just want first two elements together.


Answer: Using [regular expression](https://docs.python.org/2/howto/regex.html) ([`re`
module documentation](https://docs.python.org/2/library/re.html)):

    
    
    >>> import re
    >>> print(re.match(r'[^\\]+\\[^\\]+', r'C:\my_dir\repo\branch').group())
    C:\my_dir
    
    >>> re.findall(r'[^\\]+\\[^\\]+|.+', r'C:\my_dir\repo\branch')
    ['C:\\my_dir', '\\repo\\branch']
    

