On Fri, Oct 14, 2011 at 11:20 PM, <aaabb...@hotmail.com> wrote: > Test.py > #!/usr/bin/python > from my_lib import my_function > class my_class(my_function.name):
Why are you subclassing my_function.name and not just my_function? > def __initial__(self, name); > pass The initializer method should be named "__init__", not "__initial__". > def test(): You forgot to include "self" as a parameter, like so: def test(self): > print "this is a test" > > If __name__ == '__maim__': That should be "__main__" with an N, not "__maim__" with an M. And "if" must be in all-lowercase. > my_class.main() Your class doesn't define any method named "main" (you only defined test() and __initial__() ), so this call will fail. > --------------------------------------------------- > my_lib.py > class my_function() You're missing a colon after the parentheses. Also, you're writing a class, not a function, so please rename the class something less confusing. > Can anyone finish above code and let me try to understand > Class inheritance? > TIA. Have you read any Python tutorial? There are several basic errors in your code which would suggest that you haven't. You really ought to; it's well worth it. The Beginner's Guide links to 2 lists of tutorials: http://wiki.python.org/moin/BeginnersGuide There's also the python-tutor mailing list, which is specifically geared towards answering beginner questions: http://mail.python.org/mailman/listinfo/tutor Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list