Re: what is the the best way to express following:

2006-03-27 Thread Felipe Almeida Lessa
Em Seg, 2006-03-27 às 18:43 -0800, James Stroud escreveu: > Here is a suggestion > > todo = {(int, long):abc, (str,):afg, (tuple, list):ijk} > todo[type(key)]() Maybe... todo = {(int, long): abc, basestr: afg, (tuple, list): ijk} (y for x,y in todo.iteritems() if isinstance(key, x)).next()() Fo

Re: what is the the best way to express following:

2006-03-27 Thread James Stroud
AndyL wrote: > James Stroud wrote: > >> Here is a suggestion >> >> todo = {(int, long):abc, (str,):afg, (tuple, list):ijk} >> todo[type(key)]() > > > > Is not that a shortcut? I have got "KeyError" exception ... No, I hit send too soon, mixing ideas in my head. Paul McGuire's answer is the wa

Re: what is the the best way to express following:

2006-03-27 Thread AndyL
Paul McGuire wrote: > "AndyL" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >>if type(key).__name__ == "int" or type(key).__name__ == "long": >> abc() >>elif type(key).__name__ == "str": >> efg() >>elif type(key).__name__ == "tuple" or type(key).__name__ == "list": >> i

Re: what is the the best way to express following:

2006-03-27 Thread AndyL
James Stroud wrote: > Here is a suggestion > > todo = {(int, long):abc, (str,):afg, (tuple, list):ijk} > todo[type(key)]() Is not that a shortcut? I have got "KeyError" exception ... -- http://mail.python.org/mailman/listinfo/python-list

Re: what is the the best way to express following:

2006-03-27 Thread James Stroud
AndyL wrote: > if type(key).__name__ == "int" or type(key).__name__ == "long": > abc() > elif type(key).__name__ == "str": > efg() > elif type(key).__name__ == "tuple" or type(key).__name__ == "list": > ijk() > > > In other words I need to determinie intiger type or string or []/() in

Re: what is the the best way to express following:

2006-03-27 Thread Paul McGuire
"AndyL" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > if type(key).__name__ == "int" or type(key).__name__ == "long": > abc() > elif type(key).__name__ == "str": > efg() > elif type(key).__name__ == "tuple" or type(key).__name__ == "list": > ijk() > > > In other words

what is the the best way to express following:

2006-03-27 Thread AndyL
if type(key).__name__ == "int" or type(key).__name__ == "long": abc() elif type(key).__name__ == "str": efg() elif type(key).__name__ == "tuple" or type(key).__name__ == "list": ijk() In other words I need to determinie intiger type or string or []/() in elegant way, possibly with