View Single Post
Old 04-11-2011, 04:21 PM   #4
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by thczv View Post
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
Starson17 is offline   Reply With Quote