SlideShare a Scribd company logo
http://www.skillbrew.com
/SkillbrewTalent brewed by the
industry itself
Overview of some concepts
Pavan Verma
@YinYangPavan
Founder, P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials
© SkillBrew http://skillbrew.com
Pass by value or reference
© SkillBrew http://skillbrew.com
Pass by value of reference
 Scalars (single-items) are passed by value
• Numbers, strings
 Objects are passed by reference
• Lists, tuples, dictionaries, class instances
© SkillBrew http://skillbrew.com
* args and **kwargs
© SkillBrew http://skillbrew.com
*args and **kwargs
 Ways to pass variable number of
arguments to a function
© SkillBrew http://skillbrew.com
hasattr & getattr
© SkillBrew http://skillbrew.com
hasattr & getattr
 hasattr – Check whether the object has an
attribute with the given name.
• hasattr(object, name) -> bool
 getattr – Get a named attribute from an
object
• getattr(object, name[, default]) -> value
© SkillBrew http://skillbrew.com
isinstance & issubclass
© SkillBrew http://skillbrew.com
isinstance & issubclass
 isinstance(object, class-or-type-or-tuple) ->
bool
 Return whether an object is an instance of a
class or of a subclass thereof.
 issubclass(C, B) -> bool
 Return whether class C is a subclass (i.e., a
derived class) of class B
© SkillBrew http://skillbrew.com
super
© SkillBrew http://skillbrew.com
super
 Typically used to call a cooperative
superclass method
© SkillBrew http://skillbrew.com
New-Style vs Old-Style Classes
© SkillBrew http://skillbrew.com
New-Style vs Old-Style Classes
class NewStyleClass(object):
pass
class OldStyleClass():
pass
© SkillBrew http://skillbrew.com
New-Style vs Old-Style Classes
 New-style classes motivated by need to
provide a unified object model
 Provides ability to subclass most built-in
types, or the introduction of "descriptors",
which enable computed properties.
 Python 3 only has new-style classes. No
matter if you subclass from object or not,
classes are new-style in Python 3.
© SkillBrew http://skillbrew.com
Property
© SkillBrew http://skillbrew.com
Property
 Allows user of the class to access data as
attributes while hiding inner
implementation details
 Helps whenever a user interface has
granted attribute access and then
subsequent changes require the
intervention of a method
© SkillBrew http://skillbrew.com
MRO – Method Resolution Order
© SkillBrew http://skillbrew.com
MRO
 In case of multiple inheritance, need to define
an algorithm for resolving a method name
 New-style classes: similar to breadth first
search
 Old-style classes: depth first search
 Read more at
https://www.python.org/download/releases/2.
3/mro/
© SkillBrew http://skillbrew.com
Pickle
© SkillBrew http://skillbrew.com
Pickle
 The pickle module implements a fundamental, but
powerful algorithm for serializing and de-serializing a
Python object structure.
 “Pickling” is the process whereby a Python object
hierarchy is converted into a byte stream, and
“unpickling” is the inverse operation, whereby a byte
stream is converted back into an object hierarchy.
 Pickling (and unpickling) is alternatively known as
“serialization”, “marshalling,” or “flattening”, however, to
avoid confusion, the terms used here are “pickling” and
“unpickling”.
Python Programming Essentials - M37 - Brief Overview of Misc Concepts

More Related Content

PPTX
Python Programming Essentials - M35 - Iterators & Generators
PPTX
Python Programming Essentials - M31 - PEP 8
PPTX
Python Programming Essentials - M27 - Logging module
PPTX
Python Programming Essentials - M25 - os and sys modules
PPTX
Python Programming Essentials - M6 - Code Blocks and Indentation
PPTX
Python Programming Essentials - M21 - Exception Handling
PPTX
Python Programming Essentials - M8 - String Methods
PPTX
Python Programming Essentials - M9 - String Formatting
Python Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M31 - PEP 8
Python Programming Essentials - M27 - Logging module
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M6 - Code Blocks and Indentation
Python Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M8 - String Methods
Python Programming Essentials - M9 - String Formatting

What's hot (20)

PPTX
Python Programming Essentials - M11 - Comparison and Logical Operators
PPT
Profiling in python
PPT
Python testing
PDF
Command Line Arguments with Getopt::Long
PDF
Replace OutputIterator and Extend Range
PDF
Demonstration on keyword
PDF
Metrics ekon 14_2_kleiner
PPT
Gift-VT Tools Development Overview
PPTX
Inline Functions and Default arguments
PDF
Use of an Oscilloscope - maXbox Starter33
PPTX
Oop object oriented programing topics
PPT
CPP Language Basics - Reference
PDF
C++aptitude questions and answers
DOC
Labsheet_3
PDF
TensorFlow Lite (r1.5) & Android 8.1 Neural Network API
PDF
C++ references
PPT
Constructor,destructors cpp
PPT
FUNCTIONS IN c++ PPT
PPTX
Introduction to nsubstitute
PPT
C++ programming
Python Programming Essentials - M11 - Comparison and Logical Operators
Profiling in python
Python testing
Command Line Arguments with Getopt::Long
Replace OutputIterator and Extend Range
Demonstration on keyword
Metrics ekon 14_2_kleiner
Gift-VT Tools Development Overview
Inline Functions and Default arguments
Use of an Oscilloscope - maXbox Starter33
Oop object oriented programing topics
CPP Language Basics - Reference
C++aptitude questions and answers
Labsheet_3
TensorFlow Lite (r1.5) & Android 8.1 Neural Network API
C++ references
Constructor,destructors cpp
FUNCTIONS IN c++ PPT
Introduction to nsubstitute
C++ programming
Ad

Similar to Python Programming Essentials - M37 - Brief Overview of Misc Concepts (20)

PPT
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
PPTX
Lecture-10_PHP-OOP.pptx
PPTX
Presentation 3rd
PPTX
AI - PYTHON PROGRAMMING BASICS II.pptx
PPTX
Object Oriented Programming C#
PPT
PHP - Introduction to Object Oriented Programming with PHP
PPTX
UNIT 3- Java- Inheritance, Multithreading.pptx
PPT
Synapseindia object oriented programming in php
PPTX
PPTX
About Python
PPTX
CodeIgniter & MVC
ODP
Beginners Guide to Object Orientation in PHP
PDF
Effective Python 90 specific ways to write better Python Second Edition Brett...
PPT
Lecture02
PPTX
ExamRevision_FinalSession_C++ notes.pptx
PDF
HBase Data Types
PDF
Effective Python 90 specific ways to write better Python Second Edition Brett...
PPT
Composing High-Performance Memory Allocators with Heap Layers
PPS
Learn java
ODP
(An Extended) Beginners Guide to Object Orientation in PHP
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
Lecture-10_PHP-OOP.pptx
Presentation 3rd
AI - PYTHON PROGRAMMING BASICS II.pptx
Object Oriented Programming C#
PHP - Introduction to Object Oriented Programming with PHP
UNIT 3- Java- Inheritance, Multithreading.pptx
Synapseindia object oriented programming in php
About Python
CodeIgniter & MVC
Beginners Guide to Object Orientation in PHP
Effective Python 90 specific ways to write better Python Second Edition Brett...
Lecture02
ExamRevision_FinalSession_C++ notes.pptx
HBase Data Types
Effective Python 90 specific ways to write better Python Second Edition Brett...
Composing High-Performance Memory Allocators with Heap Layers
Learn java
(An Extended) Beginners Guide to Object Orientation in PHP
Ad

More from P3 InfoTech Solutions Pvt. Ltd. (20)

PPTX
Python Programming Essentials - M44 - Overview of Web Development
PPTX
Python Programming Essentials - M40 - Invoking External Programs
PPTX
Python Programming Essentials - M39 - Unit Testing
PPTX
Python Programming Essentials - M34 - List Comprehensions
PPTX
Python Programming Essentials - M29 - Python Interpreter and Files
PPTX
Python Programming Essentials - M28 - Debugging with pdb
PPTX
Python Programming Essentials - M24 - math module
PPTX
Python Programming Essentials - M23 - datetime module
PPTX
Python Programming Essentials - M22 - File Operations
PPTX
Python Programming Essentials - M20 - Classes and Objects
PPTX
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
PPTX
Python Programming Essentials - M18 - Modules and Packages
PPTX
Python Programming Essentials - M17 - Functions
PPTX
Python Programming Essentials - M16 - Control Flow Statements and Loops
PPTX
Python Programming Essentials - M15 - References
PPTX
Python Programming Essentials - M14 - Dictionaries
PPTX
Python Programming Essentials - M13 - Tuples
PPTX
Python Programming Essentials - M12 - Lists
PPTX
Python Programming Essentials - M10 - Numbers and Artihmetic Operators
PPTX
Python Programming Essentials - M7 - Strings
Python Programming Essentials - M44 - Overview of Web Development
Python Programming Essentials - M40 - Invoking External Programs
Python Programming Essentials - M39 - Unit Testing
Python Programming Essentials - M34 - List Comprehensions
Python Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M24 - math module
Python Programming Essentials - M23 - datetime module
Python Programming Essentials - M22 - File Operations
Python Programming Essentials - M20 - Classes and Objects
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M18 - Modules and Packages
Python Programming Essentials - M17 - Functions
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M15 - References
Python Programming Essentials - M14 - Dictionaries
Python Programming Essentials - M13 - Tuples
Python Programming Essentials - M12 - Lists
Python Programming Essentials - M10 - Numbers and Artihmetic Operators
Python Programming Essentials - M7 - Strings

Python Programming Essentials - M37 - Brief Overview of Misc Concepts