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


Groups > comp.lang.python > #57327

Re: functools and objective usage

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'attribute': 0.07; 'class,': 0.07; 'suppose': 0.07; '8bit%:30': 0.09; 'arguments': 0.09; 'caller': 0.09; '*function*': 0.16; 'arg2,': 0.16; 'attribute,': 0.16; 'finney': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'func': 0.16; 'function;': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'name)': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:usage': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'example': 0.22; 'header :User-Agent:1': 0.23; 'now?': 0.24; 'question': 0.24; 'shown': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'writes:': 0.31; 'url:python': 0.33; 'sense': 0.34; 'skip:s 30': 0.35; 'received:84': 0.35; 'object,': 0.36; 'possible': 0.36; 'url:org': 0.36; 'ben': 0.38; 'url:library': 0.38; 'to:addr :python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'is.': 0.60; 'free': 0.61; 'name': 0.63; 'such': 0.63; 'choose': 0.64; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; '8bit%:24': 0.84; 'reply-to:addr:python.org': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=PIY2p5aC c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=05MOGALpfCEA:10 a=wEDRMcl2gKoA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=2aUtDWnoeJ0A:10 a=6bRy1z0hAAAA:8 a=ynYYRegLZiipnMgRkzUA:9 a=QEXdDO2ut3YA:10 a=et3cRPM-10EA:10 a=pRukWd9pz2gA:10 a=pi0N5G7fiKIA:10
X-AUTH mrabarnett:2500
Date Wed, 23 Oct 2013 00:56:13 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: functools and objective usage
References <1382478989.4873.6.camel@debian> <7w8uxleyya.fsf@benfinney.id.au>
In-Reply-To <7w8uxleyya.fsf@benfinney.id.au>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
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.1389.1382486172.18130.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382486172 news.xs4all.nl 15866 [2001:888:2000:d::a6]:57563
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57327

Show key headers only | View raw


On 22/10/2013 23:13, Ben Finney wrote:
> Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> writes:
>
>> Suppose i have function name, 3 arguments for it, and object of its
>> caller such as self.blahbalah
>
> This doesn't make much sense to me. I think you mean: You have an
> object, ‘self.blahblah’, which has a function attribute, ‘name’.
>
Perhaps the OP means that 'name' is a variable which is bound to the
name of the function/method, which is an attribute of self.blahbalah.

> (Aside: Please choose better example names, these make it rather
> difficult to talk about.)
>
>> So:
>> my function is:
>> self.blahblah.name(arg1,arg2,arg3)
>
> Your *function* is ‘self.blahblah.name’.
>
> One possible way to express a *call* that function is
> ‘self.blahblah.name(arg1, arg2, arg3)’.
>
If 'name' is bound to the name, then:

     func = getattr(self.blahblah, name)
     func(arg1, arg2, arg3)

or just:

     getattr(self.blahblah, name)(arg1, arg2, arg3)

>> I read functools documentations, may be objictive usage and
>> functionality differ, Do you have experience with objective usage ?
>> http://docs.python.org/2/library/functools.html#partial-objects
>
> I don't understand what the question is. You have shown a way to call
> your function; what do you want to do now?
>
>> I need to use it in my class,
>
> Feel free :-)
>

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


Thread

Re: functools and objective usage MRAB <python@mrabarnett.plus.com> - 2013-10-23 00:56 +0100

csiph-web