470,810 Members | 855 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

Please help me understand this code....

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

Jul 19 '05 #1
1 905
The : is used in Python for slice notation, which is explained pretty
thoroughly in the Python tutorial, specifically at:

http://www.python.org/doc/2.4/tut/node5.html

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.