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


Groups > comp.lang.python > #28108

Re: Beginners question

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'attributes': 0.07; 'subject:question': 0.08; 'tuple': 0.09; 'aug': 0.13; 'size,': 0.13; '(note': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'helps!': 0.16; 'instance:': 0.16; 'notably': 0.16; 'wrote:': 0.17; 'thu,': 0.17; '>>>': 0.18; 'windows': 0.19; 'sort': 0.21; 'import': 0.21; 'received:209.85.214.174': 0.21; 'help.': 0.22; 'testing': 0.24; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'all.': 0.28; 'dictionary': 0.29; 'class': 0.29; "i'm": 0.29; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'thanks': 0.34; 'list': 0.35; 'so,': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'received:209': 0.37; 'far': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'help': 0.40; "you'll": 0.62; '30,': 0.62; 'is.': 0.62; 'box,': 0.69
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=kouXp0RpWAy2wNhnO7s1EFH5ixh3Y20VucAlax0UpB0=; b=eRC2yonB41VpKxZfmm84UEYfbJjjlAn3bddvk3xSsBWC8lUx0oHZt4UNx5NEzxFu3i 3up7QOlivjFFziNOunWeHSncKRuWKBHa2arvZrFVaYP5NzbUvCI0VEy62wNmFCCIh36L NAejazzyE6o2nhKCede+zRkGihCDpizYCFrqkydA4I6ZOPLngzLmMQBPUuMXBYIoP7JJ g3CrPDF4O295ZBZKq9/Bz2bvnQEpu/kTozQlPx1W+Ic0naZrUx7sUlqo/y8HRBxLquvY mi82tfoRiEcKmU6uAAmyLR2zzNMK+Tqv2met13mndq0n8T3z+Xjr4ucOdYpHNXzdpuhl dG1w==
MIME-Version 1.0
In-Reply-To <k1nk8s$3l4$1@speranza.aioe.org>
References <k1nk8s$3l4$1@speranza.aioe.org>
Date Thu, 30 Aug 2012 22:32:18 +1000
Subject Re: Beginners question
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3966.1346329941.4697.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1346329941 news.xs4all.nl 6903 [2001:888:2000:d::a6]:39620
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28108

Show key headers only | View raw


On Thu, Aug 30, 2012 at 9:54 PM,  <boltar2003@boltar.world> wrote:
> What sort of object is posix.stat_result? Its not a dictionary or list or a
> class object as far as I can tell. Thanks for any help.

There's some cool things you can do here. (Note that I'm testing this
on a Windows box, so it's marginally different.)

>>> import os
>>> st=os.stat(".")
>>> st
nt.stat_result(st_mode=16895, st_ino=36873221949168842, st_dev=0,
st_nlink=1, st_uid=0, st_gid=0, st_size=0, st_atime=1346329853,
st_mtime=1311543704, st_ctime=1306188101)
>>> help(st)

You'll get a couple of pages of help text about the object class that
the stat object is. You can do this with any object at all. Notably in
this case:

 |  This object may be accessed either as a tuple of
 |    (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)
 |  or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.

So, for instance:
>>> st[0]
16895
>>> st.st_mode
16895

Hope that helps!

ChrisA

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