Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'mrab': 0.05; 'attribute': 0.07; 'method.': 0.07; 'arguments': 0.09; 'caller': 0.09; 'function,': 0.09; 'main()': 0.09; 'none)': 0.09; 'obj': 0.09; 'skip:# 30': 0.09; 'skip:# 60': 0.09; 'def': 0.12; 'given)': 0.16; 'skip:[ 30': 0.16; 'subject:usage': 0.16; 'typeerror:': 0.16; 'skip:# 20': 0.16; 'wed,': 0.18; 'all,': 0.19; 'trying': 0.19; 'prototype': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'skip:p 30': 0.29; 'code': 0.31; '+0100,': 0.31; 'file': 0.32; 'class': 0.32; '(most': 0.33; 'created': 0.35; 'but': 0.35; 'skip:" 50': 0.36; 'yours,': 0.36; 'should': 0.36; 'thank': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'help,': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'how': 0.40; 'skip:n 10': 0.64; 'dear': 0.65; 'note:': 0.66; 'skip:m 50': 0.68; 'partial': 0.84; 'you...': 0.96 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=pahlevanzadeh.org; s=default; h=Content-Transfer-Encoding:Mime-Version:Content-Type:References:In-Reply-To:Date:To:From:Subject:Message-ID; bh=idko64Bx4VT8/IobWHl47gCvdcB7AaFeeyzeb36GUY8=; b=gI4uOqHCJC08kcAChQ+HOTDZuBRuAlT3042WYKhr4+AjFTq1ehD8+WK8xVaKiL2f/UxKntUW7sn06+BRF3o6J+ZfHkTEWa5MhsjtTdBEBHEiCDtLK2pZN/YRtWjpMujWD5BaYOVEg9vMZ6XAorveuEobca1t8N0hF9sowyUVIz8=; Subject: Re: functools and objective usage From: Mohsen Pahlevanzadeh To: python-list@python.org Date: Wed, 23 Oct 2013 21:56:44 +0330 In-Reply-To: <52681181.7090905@mrabarnett.plus.com> References: <1382478989.4873.6.camel@debian> <7w8uxleyya.fsf@benfinney.id.au> <5267109D.5040803@mrabarnett.plus.com> <1382546927.4873.13.camel@debian> <52681181.7090905@mrabarnett.plus.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.8.5-2+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - part7.royal-servers.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - pahlevanzadeh.org X-Get-Message-Sender-Via: part7.royal-servers.com: authenticated_id: mohsen@pahlevanzadeh.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382552827 news.xs4all.nl 15902 [2001:888:2000:d::a6]:54009 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57377 Oh , i changed my code to: partial(self.myinstance.myfunc,[arg1,arg2,arg3,arg4,arg5],self.myinstance) But i got the following traceback: TypeError: myfunc() takes at least 5 arguments (4 given) ##############################3 myfunc() prototype is: ######################### def myfunc(self,widget,projectFindInstance,field,data,checkBox = None,lineEdit = None) ###################################### Note: My caller location in a class and myfunc is a method. How can i use partial for this state? Yours, Mohsen > On Wed, 2013-10-23 at 19:12 +0100, MRAB wrote:h > > Dear all, > > > > I have the following code in each steps of loop: > > #################################################### > > obj = partial(self.myinstance.myfunc) > > obj.func = self.myinstance.myfunc > > obj.arg = ["TWCH",self,key,val.checkState(),val] > > obj.keywords = self.myinstance > > ######################################################## > > But i get the following traceback: > > ############################################ > > Traceback (most recent call last): > > File "./main.py", line 117, in > > main() > > File "./main.py", line 104, in main > > x.showFindProjects() > > File "/home/mohsen/codes/amlak/amlak/src/UIInterface.py", line 101, in > > showFindProjects > > self.uiProjectsFind.setupUi(self.projectsFind) > > File "/home/mohsen/codes/amlak/amlak/src/projectsFind.py", line 288, > > in setupUi > > obj.func = self.myinstance.myfunc > > TypeError: readonly attribute > > ############################################################### > > Before any help, Thank you... > > > What are you trying to do? > > Why are you trying to change obj.func? > > That attribute was set when you created the partial function, and the > other arguments should be provided at the same time. >