"johnf" <[EMAIL PROTECTED]> wrote
> Myclass.py file contains:
>
> Class one(object):
> def needsomething(self):
> Class two (object):
> def dosomething(self):
>
> I want Class one's methods to access Class two methods?
Thats pretty wierd and would suggest a problem in your class
design. Can you elaborate on why you think that would be
necessary?
What is more common is for a method to want to access
another object's methods and that is achieved by either
passing the object in as an argument to the method or
by having the instance stored in the class (possibly as a
part of initialisation)
> Class one(object):
> def needsomething(self):
> return dosomething()
return self.aTwo.dosomething()
Or
def needsomething(self,aTwo):
return aTwo.dosomething()
Do either of those scenarions meet your needs?
It is possible to access a class's methods without instantiating
the class but the results would be "interesting" in this case I
suspect.
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor