Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread DevPlayer
On Oct 15, 2:20 am, aaabb...@hotmail.com wrote: > Test.py > --- > #!/usr/bin/python > > from my_lib import my_function > > class MyClass(my_function): # usually class names start capital > > """We know you're not forgetting to document.""" > >     def __init__(self, name): > sup

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread Chris Rebert
On Sat, Oct 15, 2011 at 12:59 AM, wrote: > On 10月15日, 上午12时04分, Chris Rebert wrote: >> On Fri, Oct 14, 2011 at 11:20 PM,   wrote: >> >    my_class.main() >> >> Your class doesn't define any method named "main" (you only defined >> test() and __initial__() ), so this call will fail. > how to do

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread aaabbb16
On 10月15日, 上午12时04分, Chris Rebert wrote: > On Fri, Oct 14, 2011 at 11:20 PM,   wrote: > > Test.py > > #!/usr/bin/python > > from my_lib import test > > class my_class(my_function.name): > > Why are you subclassing my_function.name and not just my_function? try to inherit or change "name" attribute

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread Chris Rebert
On Sat, Oct 15, 2011 at 12:09 AM, Jason Swails wrote: > For instance, let's say you want to deal with shapes.  You can define a > shape via a class > > class Shape(object): >    """ Base shape class """ > Now we get into inheritance.  Let's suppose that we want a specific type of > shape.  For i

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread Jason Swails
On Sat, Oct 15, 2011 at 2:20 AM, wrote: > Test.py > #!/usr/bin/python > from my_lib import my_function > class my_class(my_function.name): > Classes must inherit from other classes -- not variables or functions. >def __initial__(self, name); > This should be "def __init__(self, name):" (:

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread Chris Rebert
On Fri, Oct 14, 2011 at 11:20 PM, 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

I am a newbie for python and try to understand class Inheritance.

2011-10-14 Thread aaabbb16
Test.py #!/usr/bin/python from my_lib import my_function class my_class(my_function.name): def __initial__(self, name); pass def test(): print "this is a test" If __name__ == '__maim__': my_class.main() --- my_lib.py class