Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:question': 0.08; 'python': 0.09; 'brackets': 0.09; 'derived': 0.09; 'modules.': 0.09; 'namespace': 0.09; 'tends': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'files.': 0.13; 'java,': 0.15; 'angle': 0.16; 'confusion': 0.16; 'subject:class': 0.16; 'usenet': 0.16; 'wrote:': 0.17; 'compilation': 0.17; 'module,': 0.17; 'module': 0.19; 'import': 0.21; 'class.': 0.23; "i've": 0.23; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:[ 10': 0.26; 'am,': 0.27; 'cc:addr:gmail.com': 0.27; 'separate': 0.27; 'module.': 0.27; "doesn't": 0.28; 'correct': 0.28; 'reply.': 0.28; 'class': 0.29; 'classes': 0.30; 'basic': 0.30; 'stuff': 0.30; 'code': 0.31; 'file': 0.32; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'nov': 0.35; 'so,': 0.35; 'posting': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'cc:no real name:2**1': 0.36; "didn't": 0.36; 'thank': 0.36; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'where': 0.40; 'group,': 0.60; 'from:no real name:2**0': 0.60; 'first': 0.61; 'organisation': 0.65; 'received:209.85.216.184': 0.84 Newsgroups: comp.lang.python Date: Tue, 6 Nov 2012 08:22:31 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=90.163.62.20; posting-account=4MmJjAoAAAAh9Xp7DS1V1sLlN8hNHPkA References: <23df4f00-2285-44cc-a9aa-aeb319d000fb@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 90.163.62.20 MIME-Version: 1.0 Subject: Re: Base class and Derived class question From: cyberirakli@gmail.com To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: cyberirakli@gmail.com, python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 159 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352218960 news.xs4all.nl 6874 [2001:888:2000:d::a6]:40908 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32829 On Tuesday, November 6, 2012 4:35:47 PM UTC+1, Ian wrote: > On Tue, Nov 6, 2012 at 8:03 AM,=20 >=20 > > I've used angle brackets just for posting here,becauze this forum doesn= 't support [code][/code] >=20 >=20 >=20 > This is a Usenet group, not a web forum. >=20 >=20 >=20 > > Just got answer, I didn't call a class it's self. Correct code is: >=20 > > class derivedClass(baseClassMod.baseClass): >=20 > > def ...... >=20 >=20 >=20 > Better style would be to import the class from the module in the first pl= ace: >=20 >=20 >=20 > from baseClass import baseClass >=20 >=20 >=20 > # ... >=20 >=20 >=20 > class derivedClass(baseClass): >=20 > # ... >=20 >=20 >=20 > Better yet would be to put both classes in the same file in the first >=20 > place. Python isn't Java, where each class is an independent >=20 > compilation unit. There is no reason to put each class in its own >=20 > separate module, and it tends to cause namespace confusion as you have >=20 > discovered. On Tuesday, November 6, 2012 4:35:47 PM UTC+1, Ian wrote: > On Tue, Nov 6, 2012 at 8:03 AM, =20 >=20 > > I've used angle brackets just for posting here,becauze this forum doesn= 't support [code][/code] >=20 >=20 >=20 > This is a Usenet group, not a web forum. >=20 >=20 >=20 > > Just got answer, I didn't call a class it's self. Correct code is: >=20 > > class derivedClass(baseClassMod.baseClass): >=20 > > def ...... >=20 >=20 >=20 > Better style would be to import the class from the module in the first pl= ace: >=20 >=20 >=20 > from baseClass import baseClass >=20 >=20 >=20 > # ... >=20 >=20 >=20 > class derivedClass(baseClass): >=20 > # ... >=20 >=20 >=20 > Better yet would be to put both classes in the same file in the first >=20 > place. Python isn't Java, where each class is an independent >=20 > compilation unit. There is no reason to put each class in its own >=20 > separate module, and it tends to cause namespace confusion as you have >=20 > discovered. On Tuesday, November 6, 2012 4:35:47 PM UTC+1, Ian wrote: >=20 > > I've used angle brackets just for posting here,becauze this forum doesn= 't support [code][/code] >=20 >=20 >=20 > This is a Usenet group, not a web forum. >=20 >=20 >=20 > > Just got answer, I didn't call a class it's self. Correct code is: >=20 > > class derivedClass(baseClassMod.baseClass): >=20 > > def ...... >=20 >=20 >=20 > Better style would be to import the class from the module in the first pl= ace: >=20 >=20 >=20 > from baseClass import baseClass >=20 >=20 >=20 > # ... >=20 >=20 >=20 > class derivedClass(baseClass): >=20 > # ... >=20 >=20 >=20 > Better yet would be to put both classes in the same file in the first >=20 > place. Python isn't Java, where each class is an independent >=20 > compilation unit. There is no reason to put each class in its own >=20 > separate module, and it tends to cause namespace confusion as you have >=20 > discovered. Thank you for reply. Of course, import just a class from the module. The re= ason of have each class in separate file is that I have a base class with b= asic functionality and a lot of derived classes from it with custom functi= onality for each class. Also, the program is modular and periodically will= need adding some new modules. So, for better organisation of all this stuf= f I have put them in separate files.