Tail implementation written in python