Python grid implementation