Assuming I have a path such as /resource/123/resourceb/b/someotherresource/
. In this case someotherresource
has no resource id. This example has 3 resources, but I need to handler anywhere between 1-4 resources.
What is a pythonic way to split it into [(a,b), (c,d), (e, None)]
Example:
x = '/resource/123/resourceb/b/someotherresource/'
xplit = x.split('/')
>>> [ 'resource', '123', 'resourceb', 'b', 'someotherresource']
import magic
# ideal result
>>> [ ('resource', '123'), ('resourceb', 'b'), ('someotherresource', None)]
I know I can do it the stupid way, but is there a simple way to split & pair an array of odd length ?