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


Groups > comp.lang.python > #76283

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

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: how to write a function to make operation as a argument in the function
Date 2014-08-14 09:52 +0100
References <53EC6603.5010906@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.12984.1408006368.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 14/08/2014 08:32, luofeiyu wrote:
> 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?
>

With a text editor after you've taken the trouble to read the docs 
instead of bombarding us with your questions.  Start here 
https://docs.python.org/3/library/operator.html#module-operator

As a slight aside would you stop top posting as well.  If you have the 
audacity to ask what that means rather than search I will be sending my 
boys around.  Please be aware, the 17 year old is a very, very vicious 
thug.  He was taught by his granddad, who used to work for the Piranha 
Brothers, see http://en.wikipedia.org/wiki/Piranha_Brothers :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Thread

Re: how to write a function to make operation as a argument in the function Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-14 09:52 +0100

csiph-web