Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76279

how to write a function to make operation as a argument in the function

Date 2014-08-14 15:32 +0800
From luofeiyu <elearn2014@gmail.com>
Subject how to write a function to make operation as a argument in the function
Newsgroups comp.lang.python
Message-ID <mailman.12980.1408002867.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

I want to write a function to make operation as a argument in the function.

|def   fun(op,x,y):
     return(x op y)|

it is my target for the funciton:

if op ="+" fun(op,3,9) =12
if op ="*" fun(op,3,9) =27

How to write it?

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

how to write a function to make operation as a argument in the function luofeiyu <elearn2014@gmail.com> - 2014-08-14 15:32 +0800

csiph-web