A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/296707.html below:

C#3.0 and lambdas

C#3.0 and lambdasSteven Bethard steven.bethard at gmail.com
Mon Sep 19 11:50:43 EDT 2005
Steven D'Aprano wrote:
> Consider this:
> 
> def func(some_tuple):
> 
> How many items should you pass in the tuple? If it takes variable
> arguments, then that works, but if you always expect a fixed number, then
> 
> def func((x, y))
> 
> is more explicit.
> 
> The only problem I have is that once you unroll the tuple like that, it is
> hardly necessary to pass the argument as a tuple. Why not just pass x and
> y as two arguments?
> 
> def func(x, y)

I generally agree with this (and follow the same guideline in my own 
APIs), but sometimes you don't have this option.  If I have a class that 
I'd like to support an indexing operation like:

    obj[x, y]

then the natural __getitem__ signature will look like:

    def __getitem__(self, (x, y)):
        ...

STeVe

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4