Table of Content

  1. Theoretical Concepts
  2. Core Concepts
  3. Object Oriented Concepts
  4. Advanced Concepts

Best Practices & Coding Conventions

  • Variables should be declared in Snake Case
  • Constants should be declared in All Caps
  • Classes should be declared using Pascal Case
  • When using triple quote string we should use double quotes

Useful Commands

# Creating Virtual Environment
python -m venv <env-name>
<env-name>\Scripts\activate
deactivate
 
# Deleting Virtual Environment
rmdir <env-name> /s
 
# Creating Requirements File
pip freeze > requirements.txt
 
# Deleting Pip Cache
pip cache dir
pip cache purge
pip cache remove <package-name>
 
# Opens the function docstring
python -m pydoc <function-name>
 
# Run the code and open REPL
python -i <application-name>

Miscellaneous Points

  1. The zfill() command can be used to add zero’s to the start of a string. The total length of the string is passed as parameter.
  2. The ord() function returns the Unicode representation of the input character. The chr() function is used to perform the reverse operation.
  3. The partition() function is used split a string always into three parts (Everything before matched term, the matched term, everything after matched term). If no match the entire string is returned as first term.
  4. The if __name__ == '__main__' syntax can be used as an entry point (main function) in Python. When we run a python application a variable called __name__ is created which will be equal to __main__ for the main script file
  5. As of Python 3.7 dictionaries are treated as a ordered collection (Insertion order is maintained)
  6. The dir() function is an inbuilt function in python which returns the list of valid attributes and methods of a given objects
  7. Python does not have static attributes like in other programming languages. Attributes set using the constructor are instance attributes while the one declared in the class body but not in any method are class attributes
  8. Python does not support the concept of Method Overloading (Same function name different parameters)
  9. re.match() is as adding ^ to the match condition
  10. Replacing the code of a function from a class during runtime is called as Monkey Patching