python gripes survey

Ryan Lowe ryanlowe0 at msn.com
Mon Aug 25 17:52:06 EDT 2003


"Afanasiy" <abelikov72 at hotmail.com> wrote in message
news:0rqkkv481p8ob48ppbdikh95kn96jb9fe1 at 4ax.com...
> On Mon, 25 Aug 2003 06:44:03 -0600, Dave Brueck <dave at pythonapocrypha.com>
> wrote:
>
> >On Monday 25 August 2003 12:14 pm, Afanasiy wrote:
> >
> >> I have a bunch, many of them hard to define, but one that I just
thought

id like to hear them if you get the chance.

> >> of I find strange sometimes is the use of tuples as near-mystery return
> >> values. I can't help but thinking a C struct with named fields is
easier
> >> to remember than a tuple with fields accessed by integer.

dont access the return values by their index; just unpack 'em.

def getFruit() :
    return 'apples', 'oranges'

apples, oranges = getFruit()


> >> Sure you can return an associative array, but in my experience the
> >> preference is to return a tuple. I'll probably get flamed for saying
so,
> >> but this is how I feel and it is unavoidable. Returning a struct in C
is
> >> easier to deal with than returning a near-mystery tuple in Python.
> >
> >A bit of an apples-to-oranges comparison, isn't it? If you prefer to
return a
> >named structure in C, the Python equivalent certainly wouldn't be a
tuple.
>
> That's exactly my point. The Python equivalent certainly isn't a tuple.
> The comparison with C is to explain, AND also happens to point to WHY code
> like this exists in libraries which come with Python.










More information about the Python-list mailing list