New question #216288 on Sikuli:
https://answers.launchpad.net/sikuli/+question/216288

Trying to test a sort of "Paint" program, how can i loop the process describe 
above? I tried this and
i don't find the way to  set  'x.txt' and 'x+1.txt" as variables, changing each 
time the file is called.
Here is:

import random

# a list called '1.txt' that contains the string "royglvubdkaw" is in the 
"C:\\python_texts\\"   folder.

alist = ('1','2','3','4','5')   #"1" already exists, the others should be 
created one by one when the for loop runs.

x = 1
for x in alist:
    inp = open("C:\\python_texts\\x.txt","r")           #open an existing file 
"x.txt"
                                                
    outp = open("C:\\python_texts\\x + 1.txt","w")      #write the result (of 
the below 'for') in
                                                                                
                #a new file.
    for line in inp:
        alist= list(line)                               #from a list in the file
        print alist
        c  = random.choice(alist)               #choose an element from the list
        print c
        alist.remove(c)                                 #remove it
        print alist
        for a in alist:
            outp.write(a)                               #write the new list in 
"x+1.txt" file
        x = x + 1


outp.close()                                            #close the file to be 
read
inp.close()                                             #close the file to be 
written


I get: 
IOError: (2, 'No such file or directory', 'C:\\python_texts\\x.txt')

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

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to