[Python-Dev] "as" mania

Steve Holden steve at holdenweb.com
Wed Mar 8 08:05:07 CET 2006


Andrew Koenig wrote:
>>Function arguments are not covered by this trick, but
>>
>>    def bar(z):
>>        (x,y) = z
>>
>>probably isn't too much overhead...
> 
> 
> It's not the machine overhead, it's the intellectual overhead.  I know there
> are some who will disagree with me, but I would find it easier to read
> 
> 	def foo(origin as (x1, y1), corner as (x2, y2)):
> 
> than to read
> 
> 	def foo(origin, corner):
> 		(x1, y1) = origin
> 		(x2, y2) = corner
> 
> It's not a big deal, but it is not completely negligible either.
> 
On the third hand, what about

  >>> def foo((x1, y1), (x2, y2)):
  ...   print x1, y1, x2, y2
  ...
  >>> origin = (10, 1)
  >>> corner = (20, 2)
  >>> foo(origin, corner)
10 1 20 2
  >>>

Follow-ups set to comp.lang.python :-)

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd                 www.holdenweb.com
Love me, love my blog         holdenweb.blogspot.com



More information about the Python-Dev mailing list