Re: classmethod & staticmethod

2007-07-25 Thread Steven D'Aprano
On Wed, 25 Jul 2007 00:55:17 +, Alex Popescu wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote in news:eRwpi.36813$G23.28496 > @newsreading01.news.tds.net: > >> On 2007-07-25, Alex Popescu <[EMAIL PROTECTED]> wrote: >>> As a matter of style, how do you figure out that class_list is >>> a class

Re: classmethod & staticmethod

2007-07-25 Thread Steven D'Aprano
On Wed, 25 Jul 2007 00:22:18 +, Alex Popescu wrote: > "Steven D'Aprano" <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > >> On Tue, 24 Jul 2007 21:35:58 +, Alex Popescu wrote: >> >>> Neil Cerutti <[EMAIL PROTECTED]> wrote in >>> news:[EMAIL PROTECTED]: >>> On 2007-07-24,

Re: classmethod & staticmethod

2007-07-25 Thread Neil Cerutti
On 2007-07-25, Alex Popescu <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote in news:eRwpi.36813$G23.28496 > @newsreading01.news.tds.net: > >> On 2007-07-25, Alex Popescu <[EMAIL PROTECTED]> wrote: >>> As a matter of style, how do you figure out that class_list is >>> a class att

Re: classmethod & staticmethod

2007-07-25 Thread Bruno Desthuilliers
Alex Popescu a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote > in news:[EMAIL PROTECTED]: > > > >>[snip...] >> >> >>Not necessarily - you can access class attributes from within an >>instance method (but obviously a classmethod cannot access instance >>attributes). >> > > What I a

Re: classmethod & staticmethod

2007-07-25 Thread Gabriel Genellina
En Tue, 24 Jul 2007 21:55:17 -0300, Alex Popescu <[EMAIL PROTECTED]> escribió: > Neil Cerutti <[EMAIL PROTECTED]> wrote in news:eRwpi.36813$G23.28496 > @newsreading01.news.tds.net: >> On 2007-07-25, Alex Popescu <[EMAIL PROTECTED]> wrote: >>> As a matter of style, how do you figure out that clas

Re: classmethod & staticmethod

2007-07-24 Thread Alex Popescu
Neil Cerutti <[EMAIL PROTECTED]> wrote in news:eRwpi.36813$G23.28496 @newsreading01.news.tds.net: > On 2007-07-25, Alex Popescu <[EMAIL PROTECTED]> wrote: >> As a matter of style, how do you figure out that class_list is >> a class attribute and not an instance attribute? (I don't >> remember seei

Re: classmethod & staticmethod

2007-07-24 Thread Neil Cerutti
On 2007-07-25, Alex Popescu <[EMAIL PROTECTED]> wrote: > As a matter of style, how do you figure out that class_list is > a class attribute and not an instance attribute? (I don't > remember seeing anything in the PEP describing the coding > style). Check out dir(MyClass) and dir(MyClass()) for so

Re: classmethod & staticmethod

2007-07-24 Thread Alex Popescu
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > On Tue, 24 Jul 2007 21:35:58 +, Alex Popescu wrote: > >> Neil Cerutti <[EMAIL PROTECTED]> wrote in >> news:[EMAIL PROTECTED]: >> >>> On 2007-07-24, Alex Popescu <[EMAIL PROTECTED]> wrote: Bruno Desthuilliers

Re: classmethod & staticmethod

2007-07-24 Thread Steven D'Aprano
On Tue, 24 Jul 2007 21:35:58 +, Alex Popescu wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > >> On 2007-07-24, Alex Popescu <[EMAIL PROTECTED]> wrote: >>> Bruno Desthuilliers <[EMAIL PROTECTED]> >>> wrote in news:[EMAIL PROTECTED]: >>> >> >> [snip...] >> >>> >>

Re: classmethod & staticmethod

2007-07-24 Thread Alex Popescu
Neil Cerutti <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > On 2007-07-24, Alex Popescu <[EMAIL PROTECTED]> wrote: >> Bruno Desthuilliers <[EMAIL PROTECTED]> >> wrote in news:[EMAIL PROTECTED]: >> > > [snip...] > >> >> class MyClass(object): >> class_list = ['a', 'b'] >> >> def instan

Re: classmethod & staticmethod

2007-07-24 Thread Neil Cerutti
On 2007-07-24, Alex Popescu <[EMAIL PROTECTED]> wrote: > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote > in news:[EMAIL PROTECTED]: > > >> >> [snip...] >> >> >> Not necessarily - you can access class attributes from within an >> instance method (but obviously a classmethod cannot access instance

Re: classmethod & staticmethod

2007-07-24 Thread Bruno Desthuilliers
james_027 a écrit : > hi, > >> The 'real' use is (are) the one(s) you'll find. FWIW, I use >> staticmethods for helper functions that don't need access to the class >> or instance but are too specific to a class to be of any use as plain >> functions. Which is not a very frequent case. Classmethod

Re: classmethod & staticmethod

2007-07-24 Thread james_027
hi, > The 'real' use is (are) the one(s) you'll find. FWIW, I use > staticmethods for helper functions that don't need access to the class > or instance but are too specific to a class to be of any use as plain > functions. Which is not a very frequent case. Classmethods are more > usefull - mostl

Re: classmethod & staticmethod

2007-07-24 Thread Bruno Desthuilliers
From > my understanding classmethod are for dealing with class attributes? Not necessarily - you can access class attributes from within an instance method (but obviously a classmethod cannot access instance attributes). > Can somebody teach me the real use of classmethod & staticmeth

Re: classmethod & staticmethod

2007-07-24 Thread Marc 'BlackJack' Rintsch
On Tue, 24 Jul 2007 03:19:05 +, james_027 wrote: > python's staticmethod is the equivalent of java staticmethod right? Correct. `staticmethod` is essentially just a function moved into a class and accessible at the class object and instances of that class. As Python opposed to Java has func

classmethod & staticmethod

2007-07-23 Thread james_027
nding classmethod are for dealing with class attributes? Can somebody teach me the real use of classmethod & staticmethod? Thanks james -- http://mail.python.org/mailman/listinfo/python-list