Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#91 closed enhancement (fixed)

use namedtuple for stat result.

Reported by: ftputiluser Owned by: schwa
Priority: minor Milestone: 3.3
Component: Library Version:
Keywords: Cc:


The information returned by stat is not intuitive:

(33152, None, None, 1, u'1004', u'1004', 6, None, 1421830200.0, None)

I know where to get the relevant docs. But it would be much easier to deal with the result, if a namedtuple would be used.

Change History (3)

comment:1 Changed 6 years ago by schwa

I just gave it a try:


class StatResult(tuple):
    Support class resembling a tuple like that returned from


StatResultBase = collections.namedtuple(
                   "StatResult", ["st_mode", "st_ino", "st_dev", "st_nlink",
                                  "st_uid", "st_gid", "st_size", "st_atime",
                                  "st_mtime", "st_ctime"])

class StatResult(StatResultBase):
    Support class resembling a tuple like that returned from

The problem is that before the StatResult constructor took one argument (the tuple with the items to use) and with the change the StatResult constructor takes 11 arguments (the tuple items).

Since StatResult is a public class for implementation of custom parsers, I don't want to change the StatResult constructor.

comment:2 Changed 6 years ago by schwa

Resolution: fixed
Status: newclosed

As you suggest, I also think the idea behind using a namedtuple isn't the class itself, but the representation of its instances. Therefore I added a repr to StatResult so that the representation looks like that of a namedtuple [c84dd64b3eea].

comment:3 Changed 6 years ago by schwa

Milestone: 3.3
Note: See TracTickets for help on using tickets.