Skip to main content
added 59 characters in body
Source Link
Anders
  • 6.2k
  • 4
  • 28
  • 31

let's say i have directory paths looking like this:

this/is/the/basedir/path/a/include
this/is/the/basedir/path/b/include
this/is/the/basedir/path/a
this/is/the/basedir/path/b

In Python, how can i split these paths up so they will look like this instead:

a/include
b/include
a
b

If i run os.path.split(path)[1] it will display:

include
include
a
b

What should i be trying out here, should i be looking at some regex command or can this be done without it? Thanks in advance.

EDIT ALL: I solved it using regular expressions, damn handy tool :)

let's say i have directory paths looking like this:

this/is/the/basedir/path/a/include
this/is/the/basedir/path/b/include
this/is/the/basedir/path/a
this/is/the/basedir/path/b

In Python, how can i split these paths up so they will look like this instead:

a/include
b/include
a
b

If i run os.path.split(path)[1] it will display:

include
include
a
b

What should i be trying out here, should i be looking at some regex command or can this be done without it? Thanks in advance.

let's say i have directory paths looking like this:

this/is/the/basedir/path/a/include
this/is/the/basedir/path/b/include
this/is/the/basedir/path/a
this/is/the/basedir/path/b

In Python, how can i split these paths up so they will look like this instead:

a/include
b/include
a
b

If i run os.path.split(path)[1] it will display:

include
include
a
b

What should i be trying out here, should i be looking at some regex command or can this be done without it? Thanks in advance.

EDIT ALL: I solved it using regular expressions, damn handy tool :)

Source Link
Anders
  • 6.2k
  • 4
  • 28
  • 31

Question about paths in Python

let's say i have directory paths looking like this:

this/is/the/basedir/path/a/include
this/is/the/basedir/path/b/include
this/is/the/basedir/path/a
this/is/the/basedir/path/b

In Python, how can i split these paths up so they will look like this instead:

a/include
b/include
a
b

If i run os.path.split(path)[1] it will display:

include
include
a
b

What should i be trying out here, should i be looking at some regex command or can this be done without it? Thanks in advance.