← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #171616]: How to append common string into an array

 

Question #171616 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/171616

    Status: Open => Answered

RaiMan proposed the following answer:
--- string concatenation with +

** mind the usage of raw string r"some-string-with-backslash"

images = ("icon1.png",icon2.png",icon3.png")
menuicon = r"C:\images\" + images[0] # gives image path of first image

or this prints the 3 image path's
for img in images:
    print r"C:\images\"+img

--- path as string variable in one place:

imgpath = r"C:\images\"

menuicon = imgpath + images[0]

--- use os.path.join to create absolute paths
import os
menuicon = os.path.join(imgpath, images[0])

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.