How to call module functions inside class instance functions?

beginner zyzhu2000 at gmail.com
Sat Aug 18 21:42:50 EDT 2007


On Aug 18, 8:13 pm, Zentrader <zentrad... at gmail.com> wrote:
> On Aug 18, 5:40 pm, beginner <zyzhu2... at gmail.com> wrote:
>
>
>
>
>
> > Hi Everyone,
>
> > I have encountered a small problems.  How to call module functions
> > inside class instance functions? For example,  calling func1 in func2
> > resulted in a compiling error.
>
> > "my module here"
>
> > def func1():
> >      print "hello"
>
> > class MyClass:
> >    def func2():
> >          #how can I call func1 here.
> >          func1() #results in an error
>
> > Thanks,
> > Geoffrey
>
> You might want to check one of the online tutorials about how to code
> classes.  Google or look at "Learning Python" herehttp://www.python-eggs.org/
> def func1():
>      print "hello"
>
> class MyClass:
>    def func2(self):
>          #how can I call func1 here.
>          func1() #results in an error
>
> MC= MyClass()
> MC.func2()- Hide quoted text -
>
> - Show quoted text -

Thanks for your help. The missing "self" is a typo of mine. It is not
the problem I am encountering. Sorry for posting the wrong code.




More information about the Python-list mailing list