Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28127

Re: Beginners question

From Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com>
Newsgroups comp.lang.python
Subject Re: Beginners question
Date 2012-08-30 16:41 +0200
Message-ID <fla4h9-caq.ln1@satorlaser.homedns.org> (permalink)
References <k1nk8s$3l4$1@speranza.aioe.org> <j444h9-tnp.ln1@satorlaser.homedns.org> <3f9d7bd0-ff48-42a2-9622-ac56f76041cc@googlegroups.com>

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Beginners question boltar2003@boltar.world - 2012-08-30 11:54 +0000
  Re: Beginners question MRAB <python@mrabarnett.plus.com> - 2012-08-30 13:14 +0100
    Re: Beginners question Roy Smith <roy@panix.com> - 2012-08-30 08:23 -0400
    Re: Beginners question boltar2003@boltar.world - 2012-08-30 12:50 +0000
      Re: Beginners question Chris Angelico <rosuav@gmail.com> - 2012-08-30 23:06 +1000
        Re: Beginners question boltar2003@boltar.world - 2012-08-30 13:16 +0000
      Re: Beginners question Dave Angel <d@davea.name> - 2012-08-30 09:23 -0400
      Re: Beginners question Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-08-30 14:30 +0100
      Re: Beginners question Terry Reedy <tjreedy@udel.edu> - 2012-08-30 14:22 -0400
  Re: Beginners question Dave Angel <d@davea.name> - 2012-08-30 08:25 -0400
    Re: Beginners question boltar2003@boltar.world - 2012-08-30 12:53 +0000
  Re: Beginners question Chris Angelico <rosuav@gmail.com> - 2012-08-30 22:32 +1000
  Re: Beginners question Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-08-30 14:49 +0200
    Re: Beginners question Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-08-30 16:41 +0200
    Re: Beginners question Hans Mulder <hansmu@xs4all.nl> - 2012-08-30 17:38 +0200
  Re: Beginners question charvigroups@gmail.com - 2012-09-04 23:28 -0700
    Re: Beginners question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-05 09:03 +0100
    Re: Beginners question Dave Angel <d@davea.name> - 2012-09-05 09:21 -0400

csiph-web