tags:

views:

169

answers:

1

reading from serial port I get once a time lines of four types, let's call those A, B, C & D and put those values into accordion queue:

now I have to write something like this:

while readfromserial:
    if A: put A in queue1
    elif B: save B
    elif C: 
        B += C 
        put B in queue1
        B="" 
    else: put in queue2

Whic is the best "Pythonic" way to do this?

+5  A: 

See this answer for alternatives, there are quite a few with various gotchas:

http://stackoverflow.com/questions/60208/replacements-for-switch-statement-in-python

Vinko Vrsalovic