problem with Sorting from Array

shanti bhushan ershantibhushan at gmail.com
Thu Feb 3 07:30:54 CET 2011


Dear All,

funtion "textPosValue " will give me key ,type and pos values from the
arrays.
This an embedded application code .
I want to execute some thing when key ==0 && type ==0 please let me
know
where to put such code i am getting confused with it


def textPosValue(data):
    str_arr1=[" 0",".@/:1","abc2",
               "def3","ghi4",
               "jkl5","mno6",
               "pqrs7","tuv8",
               "wxyz9" ]
    str_arr2=[" 0",".@/:1","ABC2",
               "DEF3","GHI4",
               "JKL5","MNO6",
               "PQRS7","TUV8",
               "WXYZ9" ]
    str_arr3=["0","1","2",
             "3","4","5",
             "6","7","8",
             "9" ]
    str_arr4=[" 0",".@/:1","?[] 2",
               "!<> 3",",&\ 4",
               "()~ 5","'{}` 6",
               ";$|^ 7","_#% 8",
               "-*+=9" ]
    str=[str_arr1,str_arr2,str_arr3,str_arr4]
    k=1
    first=0
    SecPos=0
    sts=0
    try:
        for first in range(4):
            for SecPos in range(10):
#                print "first,SecPos,str[first]
[Secpos]",first,SecPos,str[first][SecPos]
                sts=str[first][SecPos].find(data)
            #    print sts
                if (sts < 0):
                   continue
                else:
                    k=0
                    break
            if (k==0):
                print sts
                break


        return first, SecPos, sts
    except IndexError:
        return -1,-1,-1


for ch in "43.88.79.132" :
	type,key,Pos=textPosValue(ch)
	for i in range(type):
		cat,data=remote_keypress("green")
		send_sircs(cat,data)
		sleep(0.5)

	for j in range(Pos+1):
		if (key ==0 && type ==0)                                 // i want
to execute some thing when , key ==0 && type ==0 , is it the right
position??
			cat,data=remote_keypress("space")
			send_sircs(cat,data)
			sleep(0.5)
			cat,data=remote_keypress("violet")
			send_sircs(cat,data)
			sleep(0.5)

		cat,data=remote_keypress(key)
		send_sircs(cat,data)
		sleep(0.5)
	sleep(0.5)



More information about the Python-list mailing list