problem with Sorting from Array

Discussion in 'Python' started by shanti bhushan, Feb 3, 2011.

  1. 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)
     
    shanti bhushan, Feb 3, 2011
    #1
    1. Advertising

  2. shanti bhushan

    Chris Rebert Guest

    Re: problem with Sorting from Array

    On Wed, Feb 2, 2011 at 10:30 PM, shanti bhushan
    <> 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
     
    Chris Rebert, Feb 3, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. markspace
    Replies:
    1
    Views:
    388
    markspace
    Jun 25, 2009
  2. Roedy Green
    Replies:
    1
    Views:
    445
    Roedy Green
    Jun 25, 2009
  3. Replies:
    2
    Views:
    1,441
    James Kanze
    Jul 6, 2010
  4. Dominic Son

    Sorting through an array of an array

    Dominic Son, Oct 13, 2006, in forum: Ruby
    Replies:
    5
    Views:
    85
  5. Andrew Poulos

    Sorting array against other array

    Andrew Poulos, Jan 17, 2007, in forum: Javascript
    Replies:
    4
    Views:
    100
    Andrew Poulos
    Jan 23, 2007
Loading...

Share This Page