Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28108
| References | <k1nk8s$3l4$1@speranza.aioe.org> |
|---|---|
| Date | 2012-08-30 22:32 +1000 |
| Subject | Re: Beginners question |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3966.1346329941.4697.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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