top of page

1 Introduction


1.1 Introduction




2 Introductory concepts


2.1 What is an object


2.2 The function id()




3 Mutable and Immutable objects


3.1 Definition


3.2 Lists & integers: mutability and append(), +=, '='


3.3 The 'is' operator versus the '=='


3.4 The class of all classes: type


3.5 More examples on mutability: dictionaries & sets


3.6 Affecting a mutable object in & out of a function


3.7 A function that changes a list (=mutable) in but not out


3.8 Functions changing sets & dicts (=mutable) in but not out


3.9 Examples of mutable / immutable objects: list & tuples


3.10 Change mutable/immutable objects that are inside others




4 Scope


4.1 Global & local scope (functions)


4.2 Scope in if-else statements


4.3 The keyword 'global' to affect global vars from functions




5 Classes


5.1 Download the code


5.2 The constructor method


5.3 Instantiating the class


5.4 Merging objects, deleting/adding components of objects


5.5 Getter & setter methods


5.6 The @property decorator: getters & setters


5.7 More example - property decorator


5.8 More examples on @property decorator


5.9 The @property as a getter


5.10 The Encapsulation concept


5.11 Class attributes


5.12 Class methods and the @classmethod decorator


5.13 More examples of class methods


5.14 Static attributes


5.15 Static methods @staticmethod


5.16 revision on classes


5.17 Classmethods as constructors. Examples


5.18 More examples. Class methods as constructors


5.19 Private Attributes code for practice




6 Function closures and classes


6.1 Closures




7 Decorators


7.1 Create your own decorator (1 parameter)


7.2 Create your own decorator with any number of arguments


7.3 Example: A decorator for energy (GWh)


7.4 A decorator measuring runtime


7.5 Changing the return of a function with a decorator


7.6 Multiple decorators




8 Iterable objects and iterators


8.1 How to determine if an object is iterable


8.2 Manually iterating, next


8.3 Create your iterable object


8.4 Create your own iterator


8.5 A class with next and iter


8.6 iter versus iter


8.7 Implementing the range


8.8 It is not possible to reset an iterator




9 Generators


9.1 Define and call a generator


9.2 Generator versus iterator


9.3 Generator keep running till yield


9.4 next() generator


9.5 Memory advantages


9.6 Example for electricity consumption


9.7 Example range generator




10 Advanced Class Operations


10.1 Dataclass & special methods (repr, eq) & annotations


10.2 The hasattr, getattr commands


10.3 Initializing instance attributes based on Falsey values


10.4 Concatenate lists of custom objects, and, repr


10.5 Dictionary of custom objects


10.6 Make a list of custom objects, using list comprehension


10.7 How to Flatten a list of lists of custom objects


10.8 An Ordered Dictionary of custom objects


10.9 List of custom objects convert to dict of custom objects




11 Inheritance


11.1 Introduction


11.2 Why we need inheritance


11.3 Visibility child parent


11.4 Class creation using tuples and dict


11.5 Issubclass and Newtype (annotations)


11.6 Inheritance, static methods and class methods




12 Polymorphism function overloading


12.1 Method overloading - how not to


12.2 How to implement constructor overloading


12.3 Method overloading approach1


12.4 Method overloading approach2


12.5 Method overloading approach3




13 Polymorphism method overriding


13.1 Intro: Method overriding, overloading


13.2 Method overriding


13.3 Revision




14 Polymorphism Operator Overloading


14.1 Description


14.2 Example




15 Multiple inheritance


15.1 isinstance, class hierarchy


15.2 Multiple inheritance


15.3 Sequential inheritance




16 Polymorphism duck typing


16.1 Analysis




17 Abstraction


17.1 Abstract classes


17.2 Interface




18 Metaclass, superclass


18.1 Introduction


18.2 Metaclass and superclass


18.3 The power of metaclasses


18.4 Deep dive into metaclasses


18.5 Metaclass instantiation and inheritance


18.6 Inspect verify class relations


18.7 Metaclasses for making classes iterables


18.8 Concluding remarks




19 Lambda functions and objects


19.1 Nested lambda


19.2 Assigning a function to object


19.3 lambda on custom object




20 Conclusions


20.1 Conclusions

Group 591 (1).png
Group 589_edited_edited_edited_edited_edited_edited.jpg
© 2026 Dr Spyros Giannelos
London, United Kingdom
spyros@spyrosgiannelos.com
Privacy Notice 
bottom of page