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


Groups > comp.lang.python > #57378

Re: functools and objective usage

Subject Re: functools and objective usage
From Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org>
Date 2013-10-23 22:09 +0330
References (1 earlier) <7w8uxleyya.fsf@benfinney.id.au> <5267109D.5040803@mrabarnett.plus.com> <1382546927.4873.13.camel@debian> <52681181.7090905@mrabarnett.plus.com> <1382552804.4873.17.camel@debian>
Newsgroups comp.lang.python
Message-ID <mailman.1420.1382553568.18130.python-list@python.org> (permalink)

Show all headers | View raw


Another Note: class of caller and myfunc to being differed.
On Wed, 2013-10-23 at 21:56 +0330, Mohsen Pahlevanzadeh wrote:
> 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 <module>
> > >      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.
> > 
> 
> 

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


Thread

Re: functools and objective usage Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> - 2013-10-23 22:09 +0330

csiph-web