Quote:
Originally Posted by thczv
This appears to work great. Thank you. Could you explain the nuts and bolts logic of what this does, or direct me to a web site where I can learn about it?
Thanks again.
|
I thought I was going above and beyond to give you the whole list of options and why I chose split/join, but sure:
Code:
def print_version(self,url):
#split will chop up the URL into a Python list of string pieces
#each one was a string between a slash
segments = url.split('/')
#segments is now the name of that list of strings
printURL = '/'.join(segments[0:6]) + '/v-print/' + '/'.join(segments[6:])
#segments[0:6] is a list containing the first six string pieces.
# '/'.join(segments[0:6]) is a single string where the first six strings
#have been concatenated back as a single string, with the slashes put back
# segments[6:] is a list of all string pieces after the sixth
# see above for what '/'.join(segments[6:]) is
# The + signs concatenate it together, putting '/v-print/' in the middle with the slashes
return printURL
Google slice and python and list and string