Beginners question

Hans Mulder hansmu at xs4all.nl
Thu Aug 30 11:38:37 EDT 2012


On 30/08/12 14:49:54, Ulrich Eckhardt wrote:
> Am 30.08.2012 13:54, schrieb boltar2003 at boltar.world:
>>>>> s = os.stat(".")
>>>>> print s
>> posix.stat_result(st_mode=16877, st_ino=2278764L, st_dev=2053L,
>> st_nlink=2, st_u
>> id=1000, st_gid=100, st_size=4096L, st_atime=1346327745,
>> st_mtime=1346327754, st
>> _ctime=1346327754)
>>
>> What sort of object is posix.stat_result?
> 
> Use the type() function to find out. I guess that this is a named tuple,
> which is a tuple where the attributes are not indexed but have a name,
> see the documentation for the namedtuple() function from the collections
> library.

Named tuples were invented to do this kind of thing.

However, stat_result is fairly old, and named tuples
had not been invented back then.

If named tuples had been invented first, then os.stat
would probably have used them.

Hope this helps,

-- HansM





More information about the Python-list mailing list