← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #226040]: list not defined outside of a defined function?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
That is Python (like any other language):
names defined in functions (being left of a =) are local, unless otherwise stated, which means, that they are not defined outside.

In your case, the easiest way is, to return line1 from the def, if line1
is the only content from testcode(), you are interested in:


def testcode():
    line1= [4,5,2,3,1,3]
    return line1

line1 = testcode()
print line1

The other principal way is to use globals:

def testcode():
    global line1
    line1= [4,5,2,3,1,3]

testcode()
print line1

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