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

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
 

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
OOPS.pptx
NitinSharma134320
 
PPTX
software construction and development week 3 Python lists, tuples, dictionari...
MuhammadBilalAjmal2
 
PDF
Python's dynamic nature (rough slides, November 2004)
Kiran Jonnalagadda
 
PPTX
Object Oriented Programming.pptx
SAICHARANREDDYN
 
PDF
Object-Oriented Programming System presentation
PavanKumarPathipati
 
PPTX
مقدمة بايثون .pptx
AlmutasemBillahAlwas
 
PPTX
Python OOPs
Binay Kumar Ray
 
PPTX
Python-Classes.pptx
Karudaiyar Ganapathy
 
PPTX
Python lec4
Swarup Ghosh
 
PPTX
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
PPT
object oriented programming in python.ppt
AnkitaRaut26
 
PPTX
Python_Buildin_Data_types_Lecture_8.pptx
foxel54542
 
PPTX
UNIT 3 PY.pptx - OOPS CONCEPTS IN PYTHON
drkangurajuphd
 
PDF
Lecture 01 - Basic Concept About OOP With Python
National College of Business Administration & Economics ( NCBA&E)
 
PPTX
IPP-M5-C1-Classes _ Objects python -S2.pptx
DhavalaShreeBJain
 
PDF
Python Classes_ Empowering Developers, Enabling Breakthroughs.pdf
SudhanshiBakre1
 
PPT
07slide.ppt
NuurAxmed2
 
PDF
Python Classes_ Empowering Developers, Enabling Breakthroughs.pdf
SudhanshiBakre1
 
PDF
CLTL python course: Object Oriented Programming (1/3)
Rubén Izquierdo Beviá
 
PDF
singh singhsinghsinghsinghsinghsinghsinghsinghsingh.pdf
horiamommand
 
software construction and development week 3 Python lists, tuples, dictionari...
MuhammadBilalAjmal2
 
Python's dynamic nature (rough slides, November 2004)
Kiran Jonnalagadda
 
Object Oriented Programming.pptx
SAICHARANREDDYN
 
Object-Oriented Programming System presentation
PavanKumarPathipati
 
مقدمة بايثون .pptx
AlmutasemBillahAlwas
 
Python OOPs
Binay Kumar Ray
 
Python-Classes.pptx
Karudaiyar Ganapathy
 
Python lec4
Swarup Ghosh
 
PYTHON OBJECT-ORIENTED PROGRAMMING.pptx
hpearl130
 
object oriented programming in python.ppt
AnkitaRaut26
 
Python_Buildin_Data_types_Lecture_8.pptx
foxel54542
 
UNIT 3 PY.pptx - OOPS CONCEPTS IN PYTHON
drkangurajuphd
 
Lecture 01 - Basic Concept About OOP With Python
National College of Business Administration & Economics ( NCBA&E)
 
IPP-M5-C1-Classes _ Objects python -S2.pptx
DhavalaShreeBJain
 
Python Classes_ Empowering Developers, Enabling Breakthroughs.pdf
SudhanshiBakre1
 
07slide.ppt
NuurAxmed2
 
Python Classes_ Empowering Developers, Enabling Breakthroughs.pdf
SudhanshiBakre1
 
CLTL python course: Object Oriented Programming (1/3)
Rubén Izquierdo Beviá
 
singh singhsinghsinghsinghsinghsinghsinghsinghsingh.pdf
horiamommand
 
Ad

Recently uploaded (20)

PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PPTX
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PDF
Digital water marking system project report
Kamal Acharya
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
PDF
Data structures notes for unit 2 in computer science.pdf
sshubhamsingh265
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPTX
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PDF
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
Design Thinking basics for Engineers.pdf
CMR University
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
Digital water marking system project report
Kamal Acharya
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
Data structures notes for unit 2 in computer science.pdf
sshubhamsingh265
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
Distribution reservoir and service storage pptx
dhanashree78
 
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 

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