python gripes survey

Dave Brueck dave at pythonapocrypha.com
Mon Aug 25 10:44:22 EDT 2003


On Monday 25 August 2003 02:23 pm, Grant Edwards wrote:
> In article <mailman.1061838206.18981.python-list at python.org>, Dave Brueck 
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
> >> 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.
>
> [...]
>
> > 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.
>
> If you look at the library, it is.

Ah, now I get it, thanks. This is such a goofy thread anyway, but I thought it 
was about language gripes, and in the general case a simple class is the 
Python analog to a C struct.

> In instances where the "return" value to an ioctl or system
> call is a C struct, the Python return value is often a tuple.
> stat() leaps to mind as a good example.  In that case, symbolic
> indexes into the tuple are provided -- this mitigates the
> situation somewhat.

Even better, the commonly-used elements have os.path.get* acessors 
(os.path.getsize, getmtime, etc.).

-Dave





More information about the Python-list mailing list