SlideShare a Scribd company logo
The Awesome
Modules, Functions, Class, Metaclass,
OOPs Concepts.
Part-4
Summary of Previous Parts
We are done with discussing the python Installation, Environment setup, Data
types in python, Basic Data structures, their syntaxes and their usage.
In the last presentation we have covered inputs, Iterators & generators, Range &
Xrange, Operators, Control flow, Branches, Expression and Order of Operation.
We will move forward with lot many things,
I hope you enjoy the show.
2
Modules
In python a module is something that has one or many files and has atleast
one __init__.py file.
__init__.py is usualy a blank file, but the interpreter defines a directory as a
module if the file is present inside the directory.
User has the power to override the init by allowing only those methods he/she
wants to allow.
3
Functions
If you know any programming language, you should probably know functions
very well. However If you don’t, function is something that has a specific set
of code for execution of some action.
It may or may not have a return statement.
In python a typical function is defined with the help of keyword ‘def’.
Syntax:
4
Function Example
Here is a function to print all integers less than 100.
If you call the above method just by typing print_int_lt_100() it prints all
integers less than 100.
5
Class
Think of a class as a blueprint. It isn't something in itself, it simply describes how to
make something. You can create lots of objects from that blueprint - known
technically as an instance.
It is a mixture of the class mechanisms found in C++ and Modula-3.
By default class members are public.
Syntax:
6
Metaclasses
Like i said Everything in python is an object, the class definition is also an object.
Does that mean instance of any class in python is an object of object?
Yes, It is.
A metaclass is the class of a class. Like a class defines how an instance of the class behaves, a
metaclass defines how a class behaves. A class is an instance of a metaclass.
7
Object Oriented
Python In OOP programmers define not only
the datatype of a data structure,
but also the types of operations
(functions) that can be applied to
the data structure.
8
Oops Concepts like inheritance,
polymorphism etc.
Terms
class variable
data member
self
__init__
__del__
static method
class method
inheritance 9
Class Members, self, constructors and destructors
Forget about class members, data members
etc and think about an UNIT.
This UNIT has it’s attributes, methods and
what not.
A perfect example for class in real time is an
UNIT in an organisation.
Or a real time Person Class.
Person can have age, name etc and the
person can take various actions.
Then there is something called self.
There needs to be something that connects
within the unit that validates the data
member and methods.
There needs to be something or some power
that creates the instance and assigns
values.
There needs to be something that destroys
the instance.
10
Old Style vs New Style Python Classes
Old Style classes does not inherit from any
other class.
Old style classes are not there anymore in
python 3.x
Old style classes are good.
1. New style classes inherits from object or
other new style classes.
2. New style classes are The Thing now with
many new features, changed MRO
standards and many more.
3. New style classes are better.
11
ThanksStay Tuned for the next part. Enjoy !!
12

More Related Content

PPTX
The Awesome Python Class Part-5
PPTX
The Awesome Python Class Part-3
PPTX
The Awesome Python Class Part-2
PPTX
This presentation is a great introduction to both fundamental programming con...
PPTX
Python Session - 3
PDF
Python Interview Questions And Answers
PDF
Anton Kasyanov, Introduction to Python, Lecture2
PPTX
Python Session - 6
The Awesome Python Class Part-5
The Awesome Python Class Part-3
The Awesome Python Class Part-2
This presentation is a great introduction to both fundamental programming con...
Python Session - 3
Python Interview Questions And Answers
Anton Kasyanov, Introduction to Python, Lecture2
Python Session - 6

What's hot (20)

PDF
Python interview questions and answers
DOCX
Notes on c++
PPTX
Python Session - 5
PDF
Python Advanced – Building on the foundation
PPTX
Understanding Python
PDF
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
PPTX
Python Session - 4
PPTX
Introduction To Programming with Python-1
PPTX
Programming in C sesion 2
PDF
Dotnet programming concepts difference faqs- 2
PDF
Programming in C Session 1
PDF
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
PPTX
Python advance
PDF
Solid Deconstruction
PPTX
Advance python
PPTX
Python data type
PPTX
Mastering Python lesson3b_for_loops
PPTX
Python Closures Explained | What are Closures in Python | Python Closures
PPTX
Structured Languages
PPTX
Introduction To Programming with Python Lecture 2
Python interview questions and answers
Notes on c++
Python Session - 5
Python Advanced – Building on the foundation
Understanding Python
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Python Session - 4
Introduction To Programming with Python-1
Programming in C sesion 2
Dotnet programming concepts difference faqs- 2
Programming in C Session 1
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Python advance
Solid Deconstruction
Advance python
Python data type
Mastering Python lesson3b_for_loops
Python Closures Explained | What are Closures in Python | Python Closures
Structured Languages
Introduction To Programming with Python Lecture 2
Ad

Viewers also liked (20)

PDF
Python exceptions
PDF
Python Programming - X. Exception Handling and Assertions
PPTX
Python Programming Essentials - M18 - Modules and Packages
ODP
Python Modules
PPT
PDF
Python on Rails 2014
PDF
Faster Python, FOSDEM
PDF
Dive into Python Class
PDF
Python class
PDF
OOPS Advanced
PDF
The future of async i/o in Python
PDF
A deep dive into PEP-3156 and the new asyncio module
TXT
Comandos para ubuntu 400 que debes conocer
PDF
Python, do you even async?
PDF
Python master class 3
PDF
Python Async IO Horizon
PDF
Practical continuous quality gates for development process
PPTX
Async programming and python
PDF
Async Tasks with Django Channels
PDF
Introduction to SQLAlchemy ORM
Python exceptions
Python Programming - X. Exception Handling and Assertions
Python Programming Essentials - M18 - Modules and Packages
Python Modules
Python on Rails 2014
Faster Python, FOSDEM
Dive into Python Class
Python class
OOPS Advanced
The future of async i/o in Python
A deep dive into PEP-3156 and the new asyncio module
Comandos para ubuntu 400 que debes conocer
Python, do you even async?
Python master class 3
Python Async IO Horizon
Practical continuous quality gates for development process
Async programming and python
Async Tasks with Django Channels
Introduction to SQLAlchemy ORM
Ad

Similar to The Awesome Python Class Part-4 (20)

PPTX
Python-Classes.pptx
PPTX
PHP OOP Lecture - 01.pptx
PPTX
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
PPTX
software construction and development week 3 Python lists, tuples, dictionari...
PPTX
Object oriented programming in python
PDF
Oops concepts
PPTX
Intro to object oriented programming.pptx
PPT
Oops slide
PPTX
JAVA - Oops Concept.pptx
DOCX
Java OOPs Concepts.docx
PDF
CS8392-OOPS-Printed-Notes-All-Units.pdf for students
PDF
M.c.a. (sem iv)- java programming
PPTX
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
PPTX
Object oriented Programming in Python.pptx
DOC
My c++
PPTX
OOPS 46 slide Python concepts .pptx
PDF
II BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdf
PPTX
classes and objects of python object oriented
PPTX
Chapter 05 classes and objects
PDF
Object And Oriented Programing ( Oop ) Languages
Python-Classes.pptx
PHP OOP Lecture - 01.pptx
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
software construction and development week 3 Python lists, tuples, dictionari...
Object oriented programming in python
Oops concepts
Intro to object oriented programming.pptx
Oops slide
JAVA - Oops Concept.pptx
Java OOPs Concepts.docx
CS8392-OOPS-Printed-Notes-All-Units.pdf for students
M.c.a. (sem iv)- java programming
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
Object oriented Programming in Python.pptx
My c++
OOPS 46 slide Python concepts .pptx
II BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdf
classes and objects of python object oriented
Chapter 05 classes and objects
Object And Oriented Programing ( Oop ) Languages

Recently uploaded (20)

PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
composite construction of structures.pdf
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Geodesy 1.pptx...............................................
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPT
Project quality management in manufacturing
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Sustainable Sites - Green Building Construction
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Welding lecture in detail for understanding
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
composite construction of structures.pdf
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Mechanical Engineering MATERIALS Selection
UNIT 4 Total Quality Management .pptx
Geodesy 1.pptx...............................................
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Lecture Notes Electrical Wiring System Components
Operating System & Kernel Study Guide-1 - converted.pdf
Project quality management in manufacturing
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Internet of Things (IOT) - A guide to understanding
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Sustainable Sites - Green Building Construction
CYBER-CRIMES AND SECURITY A guide to understanding
Welding lecture in detail for understanding
Automation-in-Manufacturing-Chapter-Introduction.pdf

The Awesome Python Class Part-4

  • 1. The Awesome Modules, Functions, Class, Metaclass, OOPs Concepts. Part-4
  • 2. Summary of Previous Parts We are done with discussing the python Installation, Environment setup, Data types in python, Basic Data structures, their syntaxes and their usage. In the last presentation we have covered inputs, Iterators & generators, Range & Xrange, Operators, Control flow, Branches, Expression and Order of Operation. We will move forward with lot many things, I hope you enjoy the show. 2
  • 3. Modules In python a module is something that has one or many files and has atleast one __init__.py file. __init__.py is usualy a blank file, but the interpreter defines a directory as a module if the file is present inside the directory. User has the power to override the init by allowing only those methods he/she wants to allow. 3
  • 4. Functions If you know any programming language, you should probably know functions very well. However If you don’t, function is something that has a specific set of code for execution of some action. It may or may not have a return statement. In python a typical function is defined with the help of keyword ‘def’. Syntax: 4
  • 5. Function Example Here is a function to print all integers less than 100. If you call the above method just by typing print_int_lt_100() it prints all integers less than 100. 5
  • 6. Class Think of a class as a blueprint. It isn't something in itself, it simply describes how to make something. You can create lots of objects from that blueprint - known technically as an instance. It is a mixture of the class mechanisms found in C++ and Modula-3. By default class members are public. Syntax: 6
  • 7. Metaclasses Like i said Everything in python is an object, the class definition is also an object. Does that mean instance of any class in python is an object of object? Yes, It is. A metaclass is the class of a class. Like a class defines how an instance of the class behaves, a metaclass defines how a class behaves. A class is an instance of a metaclass. 7
  • 8. Object Oriented Python In OOP programmers define not only the datatype of a data structure, but also the types of operations (functions) that can be applied to the data structure. 8 Oops Concepts like inheritance, polymorphism etc.
  • 10. Class Members, self, constructors and destructors Forget about class members, data members etc and think about an UNIT. This UNIT has it’s attributes, methods and what not. A perfect example for class in real time is an UNIT in an organisation. Or a real time Person Class. Person can have age, name etc and the person can take various actions. Then there is something called self. There needs to be something that connects within the unit that validates the data member and methods. There needs to be something or some power that creates the instance and assigns values. There needs to be something that destroys the instance. 10
  • 11. Old Style vs New Style Python Classes Old Style classes does not inherit from any other class. Old style classes are not there anymore in python 3.x Old style classes are good. 1. New style classes inherits from object or other new style classes. 2. New style classes are The Thing now with many new features, changed MRO standards and many more. 3. New style classes are better. 11
  • 12. ThanksStay Tuned for the next part. Enjoy !! 12