Re: calling a class method from a menu in a different class

2010-08-03 Thread Chris Hare
Oh and Risk, I know I was calling the class object. class 1 creates the instance object class 2 tries to use the instance object so the problem is how to make class 2 knowledgable of instance object? I guess I could pass the instance object into the class, since class1 creates the instance and

Re: calling a class method from a menu in a different class

2010-08-03 Thread Chris Hare
No offense taken. I'll get getting the Google Python Style Guide today. I'll package up the code tonight and it to the group. Fortunately ( or unfortunately), it is all in one file right now. On Aug 2, 2010, at 10:31 PM, rantingrick wrote: > > Chris, > > It looks as if you are calling a cl

Re: calling a class method from a menu in a different class

2010-08-02 Thread rantingrick
Chris, It looks as if you are calling a class object and not an instance object. However i cannot be for sure because you are using improper Python style. All classes should be capwords. But here again you have used camelcase for the class identifiers "radarWidgets" and "mainDisplay", which is ba

calling a class method from a menu in a different class

2010-08-02 Thread Chris Hare
What I am trying to do is call a class function from a menu, for example displaySubMenu.add_radiobutton(label="Medium", variable=radarPanelSize, command=radarWidgets.refresh) class radarWidgets: def __init__(self,root): self.window = root

Re: Calling a class method

2010-04-17 Thread Walter Brameld IV
vsoler wrote: I have the following script: class TTT(object): def duplica(self): self.data *= 2 def __init__(self, data): self.data = data TTT.duplica(self.data) def __str__(self): return str(self.data) print obj=TTT(7) print obj And I want 14 printe

Re: Calling a class method

2010-04-17 Thread Walter Brameld IV
vsoler wrote: I have the following script: class TTT(object): def duplica(self): self.data *= 2 def __init__(self, data): self.data = data TTT.duplica(self.data) def __str__(self): return str(self.data) print obj=TTT(7) print obj And I want 14 printe

Re: Calling a class method

2010-04-17 Thread Steven D'Aprano
On Sat, 17 Apr 2010 15:44:56 +0200, Andreas Waldenburger wrote: > On Sat, 17 Apr 2010 06:09:21 -0700 (PDT) vsoler > wrote: > >> I got the following error: >> TypeError: unbound method duplica() must be called with TTT instance as >> first argument (got int instance instead) >> >> What am I doin

Re: Calling a class method

2010-04-17 Thread Andreas Waldenburger
On Sat, 17 Apr 2010 15:44:56 +0200 Andreas Waldenburger wrote: > On Sat, 17 Apr 2010 06:09:21 -0700 (PDT) vsoler > wrote: > > > I got the following error: > > TypeError: unbound method duplica() must be called with TTT instance > > as first argument (got int instance instead) > > > > What am I

Re: Calling a class method

2010-04-17 Thread Andreas Waldenburger
On Sat, 17 Apr 2010 06:09:21 -0700 (PDT) vsoler wrote: > [snip actual question] Oh and a note on vocabulary: A "class method" is a somewhat advanced topic and quite probably not what you want here. They are not used very often. What I proposed in the other post was an "instance method", which i

Re: Calling a class method

2010-04-17 Thread Andreas Waldenburger
On Sat, 17 Apr 2010 06:09:21 -0700 (PDT) vsoler wrote: > I got the following error: > TypeError: unbound method duplica() must be called with TTT instance > as first argument (got int instance instead) > > What am I doing wrong? Not reading the error message. You need to create a TTT instance

Re: Calling a class method

2010-04-17 Thread Xavier Ho
On Sat, Apr 17, 2010 at 11:09 PM, vsoler wrote: > I have the following script: > > class TTT(object): >def duplica(self): >self.data *= 2 >def __init__(self, data): >self.data = data >TTT.duplica(self.data) > You're calling duplica with the class, and not by its o

Calling a class method

2010-04-17 Thread vsoler
I have the following script: class TTT(object): def duplica(self): self.data *= 2 def __init__(self, data): self.data = data TTT.duplica(self.data) def __str__(self): return str(self.data) print obj=TTT(7) print obj And I want 14 printed (twice 7) I g

Re: calling a class method

2006-03-01 Thread John Salerno
Simon Percivall wrote: > Read this: http://users.rcn.com/python/download/Descriptor.htm > > Long story short: The type of the instance is passed along together > with the instance itself. > "Unlike static methods, class methods prepend the class reference to the argument list before calling the

Re: calling a class method

2006-03-01 Thread Simon Percivall
Read this: http://users.rcn.com/python/download/Descriptor.htm Long story short: The type of the instance is passed along together with the instance itself. -- http://mail.python.org/mailman/listinfo/python-list

calling a class method

2006-03-01 Thread John Salerno
I'm reading about class methods now and I have a question about calling them. I know it is wrong of me to assume it needs to work in a parallel manner to an instance method, but I'm curious why it doesn't. Here's the book's example: class Multi: def imeth(self, x): print self, x

Re: calling a class method in a python module

2006-02-01 Thread Farshid Lashkari
> Can anybody tell me how to call "f" in my C code? Assuming you already have a handle to an instance of MyClass this should do the trick: PyObject *func = PyObject_GetAttrString(MyClassInst,"f"); if(func) { PyObject *result = PyObject_CallObject(func,NULL); if(result) { //Do

calling a class method in a python module

2006-02-01 Thread rtuhin
Hi I am trying to write a C code to call a class function in a python module. Here's my python module: def fib(n):# write Fibonacci series up to n a, b = 0, 1 while b < n: print b, a, b = b, a+b def fib2(n): # return Fibonacci series up to n result = [] a, b =