On 05/03/2015 10:07, Alan Gauld wrote:
On 04/03/15 19:10, boB Stepp wrote:
wanted to address an item in a 3-dimensional array, I would use
something like (x, y, z) whereas the Python list form amounts to
[x][y][z] .

That's just a syntax thing, Python could have allowed single
bracketing of index, Guido chose to follow his mantra of explicit
is better than implicit. Many array based languages (including C)
also require multiple explicit indices.


You could regard this a code smell in Python. Perhaps the most repeated thing written here by beginners is something like:-

for i in range(len(this)):
    for j in range(len(that)):
        for k in range(len(other)):
            if mystruct[i][j][k] then:
                ...

An experienced Pythonista's code would maybe be:-

for x in mystruct:
    for y in x:
        for z in y:
            if z:
                ...

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to