Creating Python classes

Creating Python classes

Creating Python classes There’s our first object-oriented program! The class definition starts with the class keyword. This is followed by a name (of our choice) identifying the class, and is terminated with a colon. class MyFirstClass: pass Adding attributes We...
The diamond problem

The diamond problem

The diamond problem class A: def met(self): print("this is method from A class") class B(A): def met(self): print("this is method from B class") class C(A): def met(self): print("this is method from c class") class D(B,C): def met(self):...
Notebook Application(case study)

Notebook Application(case study)

Case study:— build a simple command-line notebook application. Notes are short memos stored in a notebook. Each note should record the day it was written and can have tags added for easy querying. It should be possible to modify notes. We also need to be able to...
zipfile

zipfile

zipfile Work with ZIP archives. The ZIP file format is a common archive and compression standard. This module provides tools to create, read, write, append, and list a ZIP file. Any advanced use of this module will require an understanding of the format, as defined in...
Handling exceptions

Handling exceptions

Handling exceptions Errors: Compile time:– like syntactical error Logical error:– wrong output Run time:– like zero divsionerror(mistake by user) Python Exception Handling – Try, Except and Finally Finally:— finally block will be executed...
Polymorphism

Polymorphism

Polymorphism example, imagine a program that plays audio files. A media player might need to load an AudioFile object and then play it. We’d put a play() method on the object, which is responsible for decompressing or extracting the audio and routing it to the...
Open chat