global name not defined
Paul McGuire
ptmcg at austin.rr._bogus_.com
Mon May 22 20:41:17 EDT 2006
"NetKev" <kevin at netkev.com> wrote in message
news:1148340731.742024.270290 at j73g2000cwa.googlegroups.com...
> You are probably right and I think I will do so but just for the sake
> of my understanding of python...I noticed somthing. process_log takes
> two arguments when called but it's definition has 3 and one of them is
> "self". So I'm thinking if I modify my warn_Admin definition to
> include "self" and then call it from process_log with
> self.warn_Admin... it will work. This explains why I was getting the
> "too many arguments" error.
>
Yes. When you invoke self.warn_Admin(x), it calls warn_Admin with 2 args,
self and x.
The reason I did not suggest this is becaus it looked like warn_Admin didn't
really use anything inside self, so why make it a method?
Looks like you are getting the method/function concepts straight.
(I'm not trying to confuse you, but you could also make warn_Admin a
staticmethod within the class, using the @staticmethod decorator. Static
methods do not pass the self argument, so making warn_Admin into a static
method would be another way to resolve this problem. But only do this if
your class, whatever it is, has something inherently about it that wants its
own warn_Admin method - otherwise, just make it a global function.)
-- Paul
More information about the Python-list
mailing list