determining the number of output arguments

Tim Hoffman timh at zute.net
Wed Nov 17 03:46:01 EST 2004


Jeremy Bowers wrote:
> Now that I think of
> it, *tuple* returns are a code smell. (Remember, "code smells" are strong
> hints of badness, not proof.) Of the easily thousands of functions in
> Python I've written, less than 10 have returned a tuple that was expected
> to be unpacked. 
> 

Hmm have ever used PIL.

Lots of returns are tuples (admittedly not variable length)

things like size are an example. (100,200) or

w,h = object.size()    #  Actually it might be a property but really I 

                        #don't see a big difference.

IMHO this doesn't warrant being wrapped in a class.

and is much better than

h = object.height()
w = object.width()

Rgds

Tim



More information about the Python-list mailing list