[Tutor] OOPs and general Python questions.

Alan Gauld alan.gauld at yahoo.co.uk
Wed Apr 19 07:04:14 EDT 2023


On 19/04/2023 09:30, mhysnm1964 at gmail.com wrote:

> What is a super class? 

It is sometimes called a base class or parent class.
It is the class that your class inherits from.
The super class of all classes is Object.

So

class Parent: pass

class Child(Parent): pass

class Grandchild(Parent, Child): pass


Parent's superclass is Object
Child's super class is Parent
Grandchild has 2 super classes, Parent and Child,
so called multiple inheritance (of which this is a really bad example!)

> Does python care the order of classes and methods?

Yes.
You must declare the classes(or import them) before they can be used as
a superclass. And if you are using multiple inheritance the order of the
superclassses makes a difference to the order in which parent methods
will be called.

> If you are using "python -m pdb script_name", can you reload the file using
> this debugging tool? I couldn't find anything which mention this?

I'm not sure what you mean but it has nothing to do with OOP.

> Chat.gpt references the ability of modifying code while the program is being
> executed. How difficult is this to achieve? 

Potentially not that difficult to do but to get it right is extremely
difficult and should never really be needed. I've done it once
in a 40 year career and even that was more just to see if I could!
There are nearly always better options.

Also be extremely wary of ChatGPT and similar tools. They are
designed to create natural sounding answers not correct ones.
They may or may not find an accurate source from which to
contruct the answer but their main focus is on chatting not
being accurate!

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos





More information about the Tutor mailing list