functools and objective usage
Mohsen Pahlevanzadeh
mohsen at pahlevanzadeh.org
Wed Oct 23 14:26:44 EDT 2013
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.
>
More information about the Python-list
mailing list