Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32822
| Date | 2012-11-06 09:13 -0500 |
|---|---|
| From | Dave Angel <d@davea.name> |
| Subject | Re: Base class and Derived class question |
| References | <fda16cf9-38dd-49ae-9f49-92bc963aac2e@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3324.1352211254.27098.python-list@python.org> (permalink) |
On 11/06/2012 08:50 AM, cyberirakli@gmail.com wrote: > Hey guys, > I'm trying to understand how is working base class and derived class. in what Python version ? > So, I have to files baseClass.py and derivedClass.py. > baseClass.py : >>>> class baseClass(): How did all those angle brackets get into the file? Are you confusing an interactive interpreter session with running source files? > def bFunction(self): This line isn't indented properly. It must be further from the left margin than the class declaration. > print "We are in a base class" > > derivedClass.py: >>>> import baseClass as baseClassMod > reload(baseClassMod) reload() isn't safe to use, and especially on a module that's been renamed while it was first imported. It's a trick to speed up debugging in the interactive interpreter, and when something goes wrong, you exit the interpreter and try again. > class derivedClass(baseClassMod): > def dFunction(self): > print "We are in a derived Class" > > buwhen I'm trying to run derivedClass.py I get this error : Again, what are you actually doing? Running that file, or playing around in the interpreter? > TypeError: Error when calling the metaclass bases > module.__init__() takes at most 2 arguments (3 given) > > Interesting thing is that if I run baseClass.py and then run : If you run baseClass.py, and get back to the bash prompt, then nothing will affect subsequent tests. >>>> class derivedClass(baseClass): > def dFunction(self): > print "We are in a derived Class" > It works fin Either use the interpreter or run from the shell. This mixing of the two is mighty confusing. -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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