Asynchronous Tasks With Django and Huey

I was working on a project and to achieve some results I wanted it to run some background process. It has to run outside the request-response cycle of request. When it comes to run async code in python, we generally use a task queue to achieve it.

Celery is the mostly used in the community and I’ve been already using it on other projects at work. But task was to run a simple task...

Read more...

rm argument list too long

We can use following command if ‘rm’ command give “rm argument list too long” error:


sudo find . -name "*.css.map" -delete



Read more...

Python Tips

layout: post title: Common python gotchas —

Mutable default arguments.

A common mistake programmer makes is using mutable arguments as default argument.

For Example:

def add_warnings(warnings=[]): warnings.append("some warning here") return warnings # calling it  add_warnings() Expected output: ['some warning here'] Output: ['some...
    

Read more...

Source Code- Python

Lifecycle of a Hello World program in python.

I always wanted to know the internals of the Python language, so I started reading the Python language implementation: CPython. To understand the basics of a program execution I tried to track the lifecycle of a simple hello world program and I would like to share my learnings.

Setup:

Building Python in your local directory:

  • Clone cpython project. git clone https://github.com/python/cpython.git
  • cd cpython.
  • Build...

    Read more...

Generate all unique permuations of an array.

Given an array of integers print all unique permutation of array.

Input:

[1, 2, 3]

Output:

[1] [2] [3] [1, 2] [1, 3] [2, 3] [1, 2, 3] 

I always had problems in understanding the algorithms of generating all permutation of array. So lets try to solve by dividing the problem into smaller problem sets. Taking [1, 2, 3] as an input, we can see that permutation...

Read more...