Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > problem with Sorting from Array

Reply
Thread Tools

problem with Sorting from Array

 
 
shanti bhushan
Guest
Posts: n/a
 
      02-03-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)
 
Reply With Quote
 
 
 
 
Chris Rebert
Guest
Posts: n/a
 
      02-03-2011
On Wed, Feb 2, 2011 at 10:30 PM, shanti bhushan
<(E-Mail Removed)> wrote:
> 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

<snip>
> * * * * * * * *if (key ==0 && type ==0) * * * * * * * * * * * * * * * * // i want


The logical-AND operator in Python is spelled "and", not "&&" as in
C-like languages.
Also, comments start with a "#", not with "//" (though you probably
already know this and seem to have merely had a momentary lapse).

I can offer no definitive guidance as to where the conditional belongs
due to your code's purpose being rather opaque. I would hazard a guess
that it should go near where you change the values of `key` and `type`
(since the condition depends upon them) and outside of any nested loop
(since you mentioned nothing about repetition).

Cheers,
Chris
--
http://blog.rebertia.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting list vs sorting vector boltar2003@boltar.world C++ 2 07-06-2010 09:40 AM
Re: Array objects get changed when sorting the array Roedy Green Java 1 06-25-2009 08:25 PM
Re: Array objects get changed when sorting the array markspace Java 1 06-25-2009 06:22 PM
Sorting array against other array Andrew Poulos Javascript 4 01-23-2007 05:49 AM
Sorting through an array of an array Dominic Son Ruby 5 10-13-2006 11:13 PM



Advertisments