Re: Using my routines as functions AND methods

2024-01-04 Thread Guenther Sohler via Python-list
Hi list The approach with defining the methods from python appears to be a very good idea and it also works for classes, defined in python side. However, when I try this one: def mytrans(self): print(self) c=cube() cls=c.__class__ cls.trans=mytrans I get this: Traceback (most recent call

Re: Using my routines as functions AND methods

2024-01-04 Thread Alan Gauld via Python-list
On 04/01/2024 04:17, Thomas Passin via Python-list wrote: >> I'm probably missing something obvious here but can't you >> just assign your function to a class member? >> >> def myFunction(obj, ...): ... >> >> class MyClass: >> myMethod = myFunction > > That works if you assign the function t

Re: Using my routines as functions AND methods

2024-01-04 Thread Thomas Passin via Python-list
On 1/3/2024 8:00 PM, Alan Gauld via Python-list wrote: On 03/01/2024 22:47, Guenther Sohler via Python-list wrote: Hi, In my cpython i have written quite some functions to modify "objects". and their python syntax is e.g.\ translate(obj, vec). e.g whereas obj is ALWAYS first argument. Howev