calling the function of one class from another class
Mridula Ramesh
mridula.ccpl at gmail.com
Tue Sep 25 01:50:01 EDT 2007
thanks! ... sorry, i lacked access to the internet for a bit there... um,
no, i'm not trying to write in java style in python, because i don't even
know java!! i tried the "self" thing but that wasnt enough. I had to (as
Furkan Kuru said) use a new instance of that class and only then call the
function - that worked fine.
so a big belated thanks, everyone!
On 22/09/2007, Mridula Ramesh <mridula.ccpl at gmail.com> wrote:
>
> hi.
>
> i currently have code structured like this:
>
> classA():
> > def __init__():
> > ..............
> > ..............
> >
> > def fnc1():
> > ....................
> > ....................
> >
> >
> > classB():
> > def __init__():
> > ........................
> > ........................
> > classA.fnc1() #this is where i get an error
> >
>
> TypeError: unbound method fnc1() must be called with classA instance as
> first argument (got nothing instead)
>
> when i do fnc1(classA) i get:
>
> NameError: global name 'fnc1' is not defined
>
> am i violating some programming rule by trying to call fnc1 in classB? i
> am only now learning OO alongside python, so i'm not sure! also, can someone
> please tell me where to go for more articles on the classes and functions
> and calling them from other places?
>
> thanks a lot!
>
> mridula.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070925/a7268e44/attachment.html>
More information about the Python-list
mailing list