python, elegant way of creating vectors
<p>what is elegant way to create set of ALL vectors of dimension N, that each element is integer between 0 and K inclusive ([0, K]).</p>

<p>my current code is :</p>

<pre><code>def nodes_init(n, k):
    nodes = {}
    e = np.identity(n)
    nodes[tuple(np.zeros(n))] = 0
    s = Set()
    s.add(tuple(np.zeros(n)))
    s_used = Set()
    while len(s) != 0:
        node = s.pop()
        if node in s_used:
            continue
        s_used.add(node)
        for i in xrange(len(e)):
            temp = node + e[i]
            temp = cap(temp, k)
            temp = tuple(temp)
            nodes[temp] = 0
            if not temp in s_used:
                s.add(temp)
    return nodes

def cap(t, k):
    for i in xrange(len(t)):
        if t[i] &gt; k:
            t[i] = k
    return t
</code></pre>

<p>and I don't like it.
keys of dictionary <code>nodes</code> are desired vectors.</p>
