Re: Class Methods help

2009-06-01 Thread Jean-Michel Pichavant
FYI, same without decorators, if you python version does not support it. class MyClass: def some_func(x): return x+2 some_func = staticmethod(some_func) JM bd satish wrote: Thanks to Tim Chase & Lie Ryan !! That was exactly what I was looking for !! It's time for me to now rea

Re: Class Methods help

2009-05-31 Thread bd satish
Thanks to Tim Chase & Lie Ryan !! That was exactly what I was looking for !! It's time for me to now read the documentation of "decorators" and @classmethod and also @staticmethod. I'm quite new to decorators... -- Satish BD On Sun, May 31, 2009 at 4:44 PM, Lie Ryan wrote: > bdsatish wrote:

Re: Class Methods help

2009-05-31 Thread Lie Ryan
bdsatish wrote: > Hi, > > I have a question regarding the difference b/w "class methods" and > "object methods". Consider for example: > > class MyClass: > x = 10 > > Now I can access MyClass.x -- I want a similar thing for functions. I > tried > > class MyClass: > def some_func(x

Re: Class Methods help

2009-05-31 Thread Tim Chase
class MyClass: def some_func(x): return x+2 When I call MyClass.some_func(10) -- it fails, with error message: TypeError: unbound method some_func() must be called with MyClass instance as first argument (got int instance instead) OK. I figured out that something like this works:

Class Methods help

2009-05-31 Thread bdsatish
Hi, I have a question regarding the difference b/w "class methods" and "object methods". Consider for example: class MyClass: x = 10 Now I can access MyClass.x -- I want a similar thing for functions. I tried class MyClass: def some_func(x): return x+2 When I call MyClass

Re: calling class methods from class methods, help?

2009-03-11 Thread Terry Reedy
Oltmans wrote: I've a multithreaded program in which I've to call class methods from class methods. Here is how my code look like (excluding imports),. Any help is highly appreciated. #!/usr/bin/env python class Requests(Thread): def __init__(self, times): Thread.__init__(self)

Re: calling class methods from class methods, help?

2009-03-11 Thread Oltmans
On Mar 11, 11:00 pm, Piet van Oostrum wrote: >                     self.html=self.SendRequest() > -- Thank you, everyone, for the help. Appreciate that. > Piet van Oostrum > URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4] > Private email: p...@vanoostrum.org- Hide quoted text - > > - Show q

Re: calling class methods from class methods, help?

2009-03-11 Thread Piet van Oostrum
> Oltmans (O) escribió: >O> I've a multithreaded program in which I've to call class methods from >O> class methods. Here is how my code look like (excluding imports),. Any >O> help is highly appreciated. >O> #!/usr/bin/env python >O> class Requests(Thread): >O> def __init__(self, times

Re: calling class methods from class methods, help?

2009-03-11 Thread Chris Rebert
On Wed, Mar 11, 2009 at 10:08 AM, Oltmans wrote: > I've a multithreaded program in which I've to call class methods from > class methods. Um, those are instance methods, not class methods. Class methods take the class itself as an argument (the parameter is typically named "cls" instead of "self"

Re: calling class methods from class methods, help?

2009-03-11 Thread MRAB
Oltmans wrote: I've a multithreaded program in which I've to call class methods from class methods. Here is how my code look like (excluding imports),. Any help is highly appreciated. #!/usr/bin/env python class Requests(Thread): def __init__(self, times): Thread.__init__(self)

Re: calling class methods from class methods, help?

2009-03-11 Thread Oltmans
On Mar 11, 10:08 pm, Oltmans wrote: >                 self.html=SendRequest() # This line throws an error and error says NameError: global name '_Requests_SendRequest' is not defined. -- http://mail.python.org/mailman/listinfo/python-list

calling class methods from class methods, help?

2009-03-11 Thread Oltmans
I've a multithreaded program in which I've to call class methods from class methods. Here is how my code look like (excluding imports),. Any help is highly appreciated. #!/usr/bin/env python class Requests(Thread): def __init__(self, times): Thread.__init__(self) self.times=ti