Power of introspection

229 views

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
229
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Power of introspection

  1. 1. PYTHON• Power of Introspection• Objects and Object Orientation
  2. 2. Power of Introspection• Object• Code looking at other modules and functions in memory as objects.• Getting information and manipulating.
  3. 3. Optional and Named Arguments• Default values for function arguments arguments.py
  4. 4. Built In Function• type Function type.py• str Function• dir Function str.py• callable Function dir.py callable.py
  5. 5. Object References• getattr function gives reference to a function without knowing its name until run time.• Works on modules as well• getattr as a Dispatcher reference.py
  6. 6. Filtering Lists• Filter expressions are evaluated and if true are included in the list filtering.py
  7. 7. Lambda Functions• One line mini functions• Function that takes any number of arguments and returns the value of a single expression lambda.py
  8. 8. Classes and Objects• Class declaration• Creating an object• Setting an attribute jeff_class.py• Creating an attribute• Deleting an attribute
  9. 9. Private Attributes• Exists within the scope of the class• Syntactic way of variable hiding private.py private_access.py
  10. 10. Doc Strings• Allows programmer to place comments directly inline for the end user to view and for the editor and compiler to read doc.py
  11. 11. Self Object• Instance of the class that you are presently working upon within a class method• Example : call -> a.class_name()• Definition will be def class_name(self) :
  12. 12. Methods• Function that is defined within a class scope• Special parameter called self which identifies the instance of the class that is being operated on by the method method.py
  13. 13. Special Methods• Initialization and Termination• __init__ allocates the object• __del__ removes the reference of the object• Can be modified to anything what we want it to do in the code init.py
  14. 14. String Conversion• __str__ method• The method can be overridden to create our own specialized string display string.py
  15. 15. Inheritance• Deriving functionalities from one into another• Purpose to write as little code as possible and use as much as possible from previous instances• Changing functionality of the base class inheritance.py
  16. 16. Multiple Inheritance• Derive properties from more than one base class at a time multiple_inheritance.py
  17. 17. Using Super• Override functionality of a base class, but still use that information in the derived class• Super() function finds the right class in the inheritance tree that implements the method which is required super.py
  18. 18. Operator Overloading• Define how the operators for that class work overload.py
  19. 19. THANK YOU

×