functools and objective usage

MRAB python at mrabarnett.plus.com
Wed Oct 23 14:12:17 EDT 2013


On 23/10/2013 17:48, Mohsen Pahlevanzadeh wrote:
> 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