def a((b,c,d),e):

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Apr 20 01:53:00 EDT 2005


AdSR wrote:
> if you haven't done so yet. It appears that you can specify a function
> explicitly to take n-tuples as arguments.
> 
> Has anyone actually used it in real code?

Yes. In PyGUI I have some point and rectangle manipulation
utilities that do things like

   def add_pt((x1, y1), (x2, y2)):
     return (x1 + y1, x2 + y2)

In cases like this, it can help to make things more concise
and probably also slightly more efficient.

 > it looks like one of those language features that make
 > committing atrocities an order of magnitude easier.

I don't remember ever being seriously burned by using it.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list