Category Archives: Python

Python magic gets

  __getattribute__ and __getattr__ and __get__ and __getitem__ Lets get into these many gets. __getattr__ if the lookup attribute does not available in instance’s __dict__, then it will call __getattr__, still if it does not get, raises an AttributeError The … Continue reading

Posted in 10min, Python | Tagged , | Leave a comment

Class variable in python

What? class A(object): inst = 1 inst is the class variable Is class variable shared across the instances? Yes. but no. Usually, in object oriented languages like c++, java, the class variables are shared across instances. But here something different. … Continue reading

Posted in Academic, General, Python | Leave a comment

Understand __mro__

python-mro.md What is mro? method resoultion order is an algorithm to choose the right method to get executed from inherited base classes. Where it is used? mro will be interesting if more than one base class is used, the method … Continue reading

Posted in 10min, Python | Tagged , | Leave a comment

import struct – a glance

What is struct in python? struct is the python module which translates binary string to python types and vice versa. if you have any binary string which comes from network stream or anywhere can be directly translated to python types. … Continue reading

Posted in 10min, General, Python | Tagged , , | Leave a comment

Avoid duplicate process copy through cron

Scenario: You are executing a background job for every x minuts periodically.The job execution time takes approximately y mins.Sometimes y > x. So, you are endup with multiple duplicate active process running at back. Effets: If duplicate process runs at … Continue reading

Posted in 10min, Flask, Python | Tagged , , | 2 Comments

Same Log messages multiple times in Python [issue]

The Mistake happened in my python loggers what ? I use Python/Flask framework to develop web applications. So, For my few usecase scripts, I have to use the logger to log the flow.I have created a common handler which workes … Continue reading

Posted in Flask, Python | Tagged , | 2 Comments

Weird thing to understand from mongoengine in Flask

Inital mongo collection I am creation a mongo dument in Flask using MongoEngine Object mapper.Simple, consider the collection name is TestMe and it has two fields (name, address). The name of the document is nava. from mongoengine import Document, connect, … Continue reading

Posted in Flask, Python | Tagged , | Leave a comment

10min python: dis assembler

10min python: dis what is dis? dis is the disassembler. It shows to you how the python interpreter executes your python code in human readable format. why do we need it? To understand and optimise your python code to make … Continue reading

Posted in 10min, Python | Tagged , , | Leave a comment

10min python: settrace

10min python: what is settrace? settrace traces each execution instruction of python script Where we can use it? If you want to trace the execution sequence and it’s control over your entire script, this should be the right utility.It does … Continue reading

Posted in 10min, Academic, Python | Tagged , | Leave a comment

Start the Captcha to Stop the Bot in Flask

Implementing reCaptcha in your form Objective We are going to learn How to add captcha field in your form to avoid the form being filled by bots.The example implementation is given in Flask.if you have some basic knowledge in python, … Continue reading

Posted in Flask, Python | Tagged , , | Leave a comment