having a little trouble trying to convert this pseudo code into python, could any help

receiveFile () {
   lastblock := 0
   newblock  := 0 ;
   repeat
      repeat
         event := getFrameFromUDP(m) ;
         case event of


         data   :  newblock := getBlockNoFromFrame(m) ;
                   transmitAckOverUDP(newblock) |
         timeout:  transmitAckOverUDP(lastblock)

         esac
      until newblock==lastblock+1 ;
      lastblock = newblock ;
      storeFrameInMemory(m)
   until frame size < 512 bytes
}

What you have problem with, could you post also your effort?

this is my attempt but need help finishing it

recieveFile ()
    {
        lastblock = 0 
        newblock = 0 
        do {
            do {
                (packet, (address,port)) = sock.recvfrom(512+4)
                event = getFrameFromUDP(m) ;
                switch(of) {
                    case data:
                        newblock = getBlockNoFromFrame(m)
                        break;
                    case timeout:
                        transmitAckOverUDP(lastblock)
                        break;
                    }
                while newblock == lastblock+1
                {
                    lastblock = newblock;
                    storeFrameInMemory(m)
                }
            while size < 512;
}

you said python right?

while (something < otherthing):
    [do this stuff]
    [down here]

and case switches become if, elif, & else.

if (data):
    [do something with data]
elif (timeout):
    [do something if timed out]
else:
    # no data, no timeout, what do we do?
    [do something else]

...no offense, i know not everyone is a python programmer, but this reminds me of that joke about how to get curly braces in python..

if (x): #{
    [do something]
#}
else: #{
    [nevermind]
#}

(they're comments)

Interestingly, Python syntax is closer to normal pseudocode than any other computer language.

commented: very true, the syntax is so obvious it almost feels 'wrong' coming from another language. +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.