Just to quote the Python docs<http://docs.python.org/2/tutorial/controlflow.html#if-statements> on the subject: "An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages."
Regards 2013/1/27 David Ripton <[email protected]> > On 01/27/2013 03:24 PM, Christian Mallwitz wrote: > > Where in C you would have something along the lines of: >> >> switch (event->keyval) { >> case GDK_Left: ... >> case GDK_BackSpace: ... >> ... >> } >> >> What is your preferred code style to handle that in Python? How about >> more than one keyval triggering the same action? >> > > If it's a small number of cases, just use if/elif. (With "or" for the > multiple value case.) > > If it's a large number of cases, you can use a dict, with functions or > methods as the values. > > -- > David Ripton [email protected] > > ______________________________**_________________ > pygtk mailing list [email protected] > http://www.daa.com.au/mailman/**listinfo/pygtk<http://www.daa.com.au/mailman/listinfo/pygtk> > Read the PyGTK FAQ: http://faq.pygtk.org/ >
_______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
