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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'argument': 0.05; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'language.': 0.14; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'slight': 0.16; 'subject: \n ': 0.16; 'subject:make': 0.16; 'language': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'posting': 0.31; 'url:wiki': 0.31; 'url:wikipedia': 0.31; 'text': 0.33; 'url:python': 0.33; 'trouble': 0.34; 'subject:the': 0.34; 'editor': 0.35; 'url:org': 0.36; 'url:library': 0.38; 'to:addr :python-list': 0.38; 'rather': 0.38; 'aside': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'read': 0.60; 'around.': 0.60; 'url:3': 0.61; "you've": 0.63; 'our': 0.64; 'charset:windows-1252': 0.65; 'here': 0.66; 'boys': 0.84; 'received:2': 0.84; 'taught': 0.96
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: how to write a function to make operation as a argument in the function
Date Thu, 14 Aug 2014 09:52:28 +0100
References <53EC6603.5010906@gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-2-98-207-127.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0
In-Reply-To <53EC6603.5010906@gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12984.1408006368.18130.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1408006368 news.xs4all.nl 2876 [2001:888:2000:d::a6]:50703
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76283

Show key headers only | 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