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
Binay Kumar Ray
 
PPTX
The Awesome Python Class Part-3
Binay Kumar Ray
 
PPTX
The Awesome Python Class Part-2
Binay Kumar Ray
 
PPTX
This presentation is a great introduction to both fundamental programming con...
rapidbounce
 
PPTX
Python Session - 3
AnirudhaGaikwad4
 
PDF
Python Interview Questions And Answers
H2Kinfosys
 
PDF
Anton Kasyanov, Introduction to Python, Lecture2
Anton Kasyanov
 
PPTX
Python Session - 6
AnirudhaGaikwad4
 
The Awesome Python Class Part-5
Binay Kumar Ray
 
The Awesome Python Class Part-3
Binay Kumar Ray
 
The Awesome Python Class Part-2
Binay Kumar Ray
 
This presentation is a great introduction to both fundamental programming con...
rapidbounce
 
Python Session - 3
AnirudhaGaikwad4
 
Python Interview Questions And Answers
H2Kinfosys
 
Anton Kasyanov, Introduction to Python, Lecture2
Anton Kasyanov
 
Python Session - 6
AnirudhaGaikwad4
 

What's hot (20)

PDF
Python interview questions and answers
kavinilavuG
 
DOCX
Notes on c++
Selvam Edwin
 
PPTX
Python Session - 5
AnirudhaGaikwad4
 
PDF
Python Advanced – Building on the foundation
Kevlin Henney
 
PPTX
Understanding Python
Kaleem Ullah Mangrio
 
PDF
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Ranel Padon
 
PPTX
Python Session - 4
AnirudhaGaikwad4
 
PPTX
Introduction To Programming with Python-1
Syed Farjad Zia Zaidi
 
PPTX
Programming in C sesion 2
Prerna Sharma
 
PDF
Dotnet programming concepts difference faqs- 2
Umar Ali
 
PDF
Programming in C Session 1
Prerna Sharma
 
PDF
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Codemotion
 
PPTX
Python advance
Deepak Chandella
 
PDF
Solid Deconstruction
Kevlin Henney
 
PPTX
Advance python
pulkit agrawal
 
PPTX
Python data type
nuripatidar
 
PPTX
Mastering Python lesson3b_for_loops
Ruth Marvin
 
PPTX
Python Closures Explained | What are Closures in Python | Python Closures
Intellipaat
 
PPTX
Structured Languages
Mufaddal Nullwala
 
PPTX
Introduction To Programming with Python Lecture 2
Syed Farjad Zia Zaidi
 
Python interview questions and answers
kavinilavuG
 
Notes on c++
Selvam Edwin
 
Python Session - 5
AnirudhaGaikwad4
 
Python Advanced – Building on the foundation
Kevlin Henney
 
Understanding Python
Kaleem Ullah Mangrio
 
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Ranel Padon
 
Python Session - 4
AnirudhaGaikwad4
 
Introduction To Programming with Python-1
Syed Farjad Zia Zaidi
 
Programming in C sesion 2
Prerna Sharma
 
Dotnet programming concepts difference faqs- 2
Umar Ali
 
Programming in C Session 1
Prerna Sharma
 
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Codemotion
 
Python advance
Deepak Chandella
 
Solid Deconstruction
Kevlin Henney
 
Advance python
pulkit agrawal
 
Python data type
nuripatidar
 
Mastering Python lesson3b_for_loops
Ruth Marvin
 
Python Closures Explained | What are Closures in Python | Python Closures
Intellipaat
 
Structured Languages
Mufaddal Nullwala
 
Introduction To Programming with Python Lecture 2
Syed Farjad Zia Zaidi
 
Ad

Viewers also liked (20)

PDF
Python exceptions
rikbyte
 
PDF
Python Programming - X. Exception Handling and Assertions
Ranel Padon
 
PPTX
Python Programming Essentials - M18 - Modules and Packages
P3 InfoTech Solutions Pvt. Ltd.
 
ODP
Python Modules
Nitin Reddy Katkam
 
PPT
Summarizing
Suzan Tiemroth-zavala
 
PDF
Python on Rails 2014
Albert O'Connor
 
PDF
Faster Python, FOSDEM
Victor Stinner
 
PDF
Dive into Python Class
Jim Yeh
 
PDF
Python class
건희 김
 
PDF
OOPS Advanced
Madhavan Malolan
 
PDF
The future of async i/o in Python
Saúl Ibarra Corretgé
 
PDF
A deep dive into PEP-3156 and the new asyncio module
Saúl Ibarra Corretgé
 
TXT
Comandos para ubuntu 400 que debes conocer
Geek Advisor Freddy
 
PDF
Python, do you even async?
Saúl Ibarra Corretgé
 
PDF
Python master class 3
Chathuranga Bandara
 
PDF
Python Async IO Horizon
Lukasz Dobrzanski
 
PDF
Practical continuous quality gates for development process
Andrii Soldatenko
 
PPTX
Async programming and python
Chetan Giridhar
 
PDF
Async Tasks with Django Channels
Albert O'Connor
 
PDF
Introduction to SQLAlchemy ORM
Jason Myers
 
Python exceptions
rikbyte
 
Python Programming - X. Exception Handling and Assertions
Ranel Padon
 
Python Programming Essentials - M18 - Modules and Packages
P3 InfoTech Solutions Pvt. Ltd.
 
Python Modules
Nitin Reddy Katkam
 
Python on Rails 2014
Albert O'Connor
 
Faster Python, FOSDEM
Victor Stinner
 
Dive into Python Class
Jim Yeh
 
Python class
건희 김
 
OOPS Advanced
Madhavan Malolan
 
The future of async i/o in Python
Saúl Ibarra Corretgé
 
A deep dive into PEP-3156 and the new asyncio module
Saúl Ibarra Corretgé
 
Comandos para ubuntu 400 que debes conocer
Geek Advisor Freddy
 
Python, do you even async?
Saúl Ibarra Corretgé
 
Python master class 3
Chathuranga Bandara
 
Python Async IO Horizon
Lukasz Dobrzanski
 
Practical continuous quality gates for development process
Andrii Soldatenko
 
Async programming and python
Chetan Giridhar
 
Async Tasks with Django Channels
Albert O'Connor
 
Introduction to SQLAlchemy ORM
Jason Myers
 
Ad

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

PPTX
Python-Classes.pptx
Karudaiyar Ganapathy
 
PPTX
PHP OOP Lecture - 01.pptx
Atikur Rahman
 
PPTX
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
sg4795
 
PPTX
software construction and development week 3 Python lists, tuples, dictionari...
MuhammadBilalAjmal2
 
PPTX
Object oriented programming in python
nitamhaske
 
PDF
Oops concepts
ACCESS Health Digital
 
PPTX
Intro to object oriented programming.pptx
RafiaZafar19
 
PPT
Oops slide
Ashok Sharma
 
PPTX
JAVA - Oops Concept.pptx
ayankamila005
 
DOCX
Java OOPs Concepts.docx
FredWauyo
 
PDF
CS8392-OOPS-Printed-Notes-All-Units.pdf for students
KaviShetty
 
PDF
M.c.a. (sem iv)- java programming
Praveen Chowdary
 
PPTX
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
PPTX
Object oriented Programming in Python.pptx
SHAIKIRFAN715544
 
DOC
My c++
snathick
 
PPTX
OOPS 46 slide Python concepts .pptx
mrsam3062
 
PDF
II BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdf
rajeswaria21
 
PPTX
classes and objects of python object oriented
VineelaThonduri
 
PPTX
Chapter 05 classes and objects
Praveen M Jigajinni
 
PDF
Object And Oriented Programing ( Oop ) Languages
Jessica Deakin
 
Python-Classes.pptx
Karudaiyar Ganapathy
 
PHP OOP Lecture - 01.pptx
Atikur Rahman
 
Kripanshu MOOC PPT - Kripanshu Shekhar Jha (1).pptx
sg4795
 
software construction and development week 3 Python lists, tuples, dictionari...
MuhammadBilalAjmal2
 
Object oriented programming in python
nitamhaske
 
Oops concepts
ACCESS Health Digital
 
Intro to object oriented programming.pptx
RafiaZafar19
 
Oops slide
Ashok Sharma
 
JAVA - Oops Concept.pptx
ayankamila005
 
Java OOPs Concepts.docx
FredWauyo
 
CS8392-OOPS-Printed-Notes-All-Units.pdf for students
KaviShetty
 
M.c.a. (sem iv)- java programming
Praveen Chowdary
 
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
Object oriented Programming in Python.pptx
SHAIKIRFAN715544
 
My c++
snathick
 
OOPS 46 slide Python concepts .pptx
mrsam3062
 
II BCA JAVA PROGRAMMING NOTES FOR FIVE UNITS.pdf
rajeswaria21
 
classes and objects of python object oriented
VineelaThonduri
 
Chapter 05 classes and objects
Praveen M Jigajinni
 
Object And Oriented Programing ( Oop ) Languages
Jessica Deakin
 

Recently uploaded (20)

PDF
Queuing formulas to evaluate throughputs and servers
gptshubham
 
PPTX
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
PDF
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PDF
Software Testing Tools - names and explanation
shruti533256
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PDF
A Framework for Securing Personal Data Shared by Users on the Digital Platforms
ijcncjournal019
 
PPTX
easa module 3 funtamental electronics.pptx
tryanothert7
 
PPTX
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
VinayB68
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PPTX
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
PPTX
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 
PDF
6th International Conference on Artificial Intelligence and Machine Learning ...
gerogepatton
 
PDF
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
PPTX
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
ghousebhasha2007
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
Queuing formulas to evaluate throughputs and servers
gptshubham
 
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
Software Testing Tools - names and explanation
shruti533256
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
A Framework for Securing Personal Data Shared by Users on the Digital Platforms
ijcncjournal019
 
easa module 3 funtamental electronics.pptx
tryanothert7
 
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
VinayB68
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
Azure-DevOps-Training presentation downloadable
NamanGoyal428595
 
6th International Conference on Artificial Intelligence and Machine Learning ...
gerogepatton
 
Activated Carbon for Water and Wastewater Treatment_ Integration of Adsorptio...
EmilianoRodriguezTll
 
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
ghousebhasha2007
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 

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