records = [

def do_foo(x,y):
    print 'foo\t{0}{1}'.format(x,y)

def do_bar(s):
    print 'bar\t{0}'.format(s)

for tag , *args in records:
    if tag == 'foo':
    elif tag == 'bar':

when i run the above program , i get invalid syntax .I dono why this happens? Can someone help me please?

I think it works only with recent versions of python. For me, it works with python 3.4 but not with 2.7.

Edit: you can write

for rec in records:
    tag, args = rec[0], rec[1:]
commented: awesome :D +6

Advanced unpacking only works with Python3. Here is an example ...

# advanced unpacking ...
a, b, *rest = range(10)
print(a)     # 0
print(b)     # 1
print(rest)  # [2, 3, 4, 5, 6, 7, 8, 9]

let's hope you are not building yourself up to be one of those signature spammers.

What else could it be?