Python

Properties In Python

Properties in python are used to provide access methods to change an attribute of a class. By providing getter, setter, deleter methods, properties provide abstraction over the internal representation of the data. Property functions can range from data type validation, to any enrichment and calculation. By adding a @property decorator, a method in python can be accessed like a variable. Any processing can be performed at the retrieval or at the setting of value. Sample Read more…

Python

Decorators in Python

Decorators or Wrappers (@) in python are used to provide additional characteristic to a function. In other words a decorator wraps a function, modifying its behavior. These are simply other python functions which return functions as return values. Few common usages of decorators are @login_required: To validate if a user is logged in, otherwise load the login page @memoize: To cache return value of a function based upon arguments @patch: To monkey patch a module Read more…