Please help me understand this code....

randy randy at randyedmonds.com
Fri Jun 17 21:19:41 CEST 2005


Hello,
I am a programmer, but not a python guy. So I am a little confused with
the following python code. Specifically what does the ":" do in the
array arithmetic?

    new_page = map[opage]
    old_page = map[opage^1]


    center = new_page[1:-1,1:-1]
    origcenter = array(center)
    center[:] = old_page[2:,2:]

    center += old_page[1:-1,2:]
    center += old_page[:-2,2:]
    center += old_page[2:,1:-1]
    center += old_page[:-2,1:-1]
    center += old_page[2:,:-2]
    center += old_page[1:-1,:-2]
    center += old_page[:-2,:-2]
    center >>= 2
    center -= origcenter
    center -= (center>>density)



Thanks!!
Randy




More information about the Python-list mailing list