Am 30.08.2012 15:27, schrieb Marco Nawijn:
On Thursday, August 30, 2012 3:15:03 PM UTC+2, Ulrich Eckhardt wrote:
Am 30.08.2012 13:54, schrieb boltar2003@boltar.world:
What sort of object is posix.stat_result?
[...]
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.
It is not a namedtuple. Because a namedtuple "is" a tuple and therefore
isinstance(s, tuple) would have returned True.
from collections import namedtuple
Point = namedtuple('Point', 'x y')
p = Point(10,2)
isinstance(p, tuple)
True
Hi Marco,
I don't find anything wrong with what you say, the output formatting
from using a type created by namedtuple would have been slightly
different indeed. However, I also don't understand the point you're
trying to make, in particular why it matters that a namedtuple type is
derived from tuple, other than perhaps that access by name is available
in addition to access by index.
Greetings!
Uli
--
http://mail.python.org/mailman/listinfo/python-list