Is there something similar to ?: operator (C/C++) in Python?

Roy Smith roy at panix.com
Sun Jun 19 12:43:21 EDT 2005


In article <d9461f$olg$1 at joe.rice.edu>, Bo Peng <bpeng at rice.edu> wrote:

> Roy Smith wrote:
> 
> > Can you give us some idea of what it is that you're trying to do?  It 
> > pretty unusual to see 
> > a requirement like that.
> 
> def func(type_of_obj1, type_of_obj2, .....):
>    callfunc( [
>      type_of_obj1 and obj1a() or obj1b(),
>      type_of_obj2 and obj2a() or obj2b(),
>      ....
>      ])

I'm still not sure what the big picture is, but I suspect if you're 
switching on object types, you're doing something wrong, or at least 
unpythonic.



More information about the Python-list mailing list