Transforming a str to an operator

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Aug 28 16:58:13 CEST 2009


En Fri, 28 Aug 2009 01:50:37 -0300, Xavier Ho <contact at xavierho.com>  
escribió:
> On Fri, Aug 28, 2009 at 2:35 PM, Ben Finney
> <ben+python at benfinney.id.au<ben%2Bpython at benfinney.id.au>
>> wrote:
>
>>    op_funcs = {
>>        '+': operator.add,
>>        '-': operator.sub,
>>        '*': operator.mul,
>>        '/': operator.div,
>>        }
>>    op_prompt = "Select an operator ({}):".format(','.join(op for op in
>> op_funcs))

op_prompt = "Select an operator ({}):".format(','.join(op_funcs))

> Just fixing the code a little to be more "Pythonic" ;).

Even more ;)

-- 
Gabriel Genellina




More information about the Python-list mailing list