Hi group,

just out of curiosity, is there a list of all the syntactic sugar that
is used in python? If there isn't such a list, could it be put on a
wiki somewhere? The bit of sugar that I do know have helped me a lot in
understanding the inner workings of python.

To give a few examples (might not be totally correct):

x[i] -> x.__getitem__(i)
x[a:b] -> x.__getitem__(slice(a,b,None))
x+y -> x._add__(y)
x.method(a) -> call (x.__dict__[method], self, a) ??
for i in x: f(i) -> it = iter(x); while True: i = it.next(); f(i) ....
except stop: pass

TIA,
Bas

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to