Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32829

Re: Base class and Derived class question

Newsgroups comp.lang.python
Date 2012-11-06 08:22 -0800
References <fda16cf9-38dd-49ae-9f49-92bc963aac2e@googlegroups.com> <mailman.3324.1352211254.27098.python-list@python.org> <23df4f00-2285-44cc-a9aa-aeb319d000fb@googlegroups.com> <mailman.3328.1352216117.27098.python-list@python.org>
Subject Re: Base class and Derived class question
From cyberirakli@gmail.com
Message-ID <mailman.3330.1352218960.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Tuesday, November 6, 2012 4:35:47 PM UTC+1, Ian wrote:
> On Tue, Nov 6, 2012 at 8:03 AM, 
> 
> > I've used angle brackets just for posting here,becauze this forum doesn't support [code][/code]
> 
> 
> 
> This is a Usenet group, not a web forum.
> 
> 
> 
> > Just got answer, I didn't call a class it's self.  Correct code is:
> 
> > class derivedClass(baseClassMod.baseClass):
> 
> >     def ......
> 
> 
> 
> Better style would be to import the class from the module in the first place:
> 
> 
> 
>     from baseClass import baseClass
> 
> 
> 
>     # ...
> 
> 
> 
>     class derivedClass(baseClass):
> 
>         # ...
> 
> 
> 
> Better yet would be to put both classes in the same file in the first
> 
> place.  Python isn't Java, where each class is an independent
> 
> compilation unit.  There is no reason to put each class in its own
> 
> separate module, and it tends to cause namespace confusion as you have
> 
> discovered.



On Tuesday, November 6, 2012 4:35:47 PM UTC+1, Ian wrote:
> On Tue, Nov 6, 2012 at 8:03 AM,  
> 
> > I've used angle brackets just for posting here,becauze this forum doesn't support [code][/code]
> 
> 
> 
> This is a Usenet group, not a web forum.
> 
> 
> 
> > Just got answer, I didn't call a class it's self.  Correct code is:
> 
> > class derivedClass(baseClassMod.baseClass):
> 
> >     def ......
> 
> 
> 
> Better style would be to import the class from the module in the first place:
> 
> 
> 
>     from baseClass import baseClass
> 
> 
> 
>     # ...
> 
> 
> 
>     class derivedClass(baseClass):
> 
>         # ...
> 
> 
> 
> Better yet would be to put both classes in the same file in the first
> 
> place.  Python isn't Java, where each class is an independent
> 
> compilation unit.  There is no reason to put each class in its own
> 
> separate module, and it tends to cause namespace confusion as you have
> 
> discovered.



On Tuesday, November 6, 2012 4:35:47 PM UTC+1, Ian wrote:

> 
> > I've used angle brackets just for posting here,becauze this forum doesn't support [code][/code]
> 
> 
> 
> This is a Usenet group, not a web forum.
> 
> 
> 
> > Just got answer, I didn't call a class it's self.  Correct code is:
> 
> > class derivedClass(baseClassMod.baseClass):
> 
> >     def ......
> 
> 
> 
> Better style would be to import the class from the module in the first place:
> 
> 
> 
>     from baseClass import baseClass
> 
> 
> 
>     # ...
> 
> 
> 
>     class derivedClass(baseClass):
> 
>         # ...
> 
> 
> 
> Better yet would be to put both classes in the same file in the first
> 
> place.  Python isn't Java, where each class is an independent
> 
> compilation unit.  There is no reason to put each class in its own
> 
> separate module, and it tends to cause namespace confusion as you have
> 
> discovered.



Thank you for reply. Of course, import just a class from the module. The reason of have each class in separate file is that I have a base class with basic functionality  and a lot of derived classes from it with custom functionality for each class. Also,  the program is modular and periodically will need adding some new modules. So, for better organisation of all this stuff I have put them in separate files.  

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Base class and Derived class question cyberirakli@gmail.com - 2012-11-06 05:50 -0800
  Re: Base class and Derived class question Dave Angel <d@davea.name> - 2012-11-06 09:13 -0500
    Re: Base class and Derived class question cyberirakli@gmail.com - 2012-11-06 07:03 -0800
      Re: Base class and Derived class question Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-06 08:34 -0700
        Re: Base class and Derived class question cyberirakli@gmail.com - 2012-11-06 08:22 -0800
        Re: Base class and Derived class question cyberirakli@gmail.com - 2012-11-06 08:22 -0800
    Re: Base class and Derived class question cyberirakli@gmail.com - 2012-11-06 07:03 -0800
  Re: Base class and Derived class question cyberirakli@gmail.com - 2012-11-06 07:08 -0800
    Re: Base class and Derived class question alex23 <wuwei23@gmail.com> - 2012-11-06 18:10 -0800

csiph-web