> What is still unclear to me, is what the staticmethods are for, though: > since the reference to the object instance or to the class object are > stripped away from the call, I wonder why not to use a module function > instead.
First recall that xsstatic methods were historically the first attempt at giving Python class methods. (They were called staticmethods because C++ and Java define their class methods using the label 'static' ) The static method is still inside the class so it provides namespace protection. Thus if we want to create a search class method in each of three classes within the same module we can do so, whereas a module function would need to take the class as an input parameter and probably then do a if/else type switch statement to manipulate/access the class attributes etc. Or you write 3 functions, one per class. Neither is very OO in approach. But a classmethod would be equally suitable, if not better. > The only difference I can think of between the two (static method and > module function) is that the namespaces they "live in" are different And that is significant. Alan G _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
