Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28107
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <d@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '(using': 0.07; 'attributes': 0.07; 'class,': 0.07; 'trailing': 0.07; 'subject:question': 0.08; 'python': 0.09; 'brackets': 0.09; 'fetch': 0.09; 'function:': 0.09; 'instance.': 0.09; 'items)': 0.09; 'tuple': 0.09; 'tuple.': 0.09; 'cc:addr:python-list': 0.10; 'attributes.': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'typing': 0.17; 'skip:p 30': 0.20; 'question.': 0.20; 'sort': 0.21; 'help.': 0.22; 'cc:2**0': 0.23; 'class.': 0.23; '(this': 0.24; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'wondering': 0.26; 'am,': 0.27; '>>>>': 0.29; 'dictionary': 0.29; 'methods.': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; "i'm": 0.29; 'stuff': 0.30; 'url:python': 0.32; 'print': 0.32; 'done': 0.34; 'thanks': 0.34; 'list': 0.35; 'something': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'method': 0.36; 'far': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'url:docs': 0.38; 'shows': 0.38; 'received:192': 0.39; 'notice': 0.39; 'called': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'range': 0.60; 'link': 0.60; 'leading': 0.61; 'more': 0.63; 'teaching': 0.66; 'header :Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'special': 0.73; 'square': 0.75; 'dumb': 0.84; 'received:74.208.4.194': 0.84 |
| Date | Thu, 30 Aug 2012 08:25:33 -0400 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 |
| MIME-Version | 1.0 |
| To | boltar2003@boltar.world |
| Subject | Re: Beginners question |
| References | <k1nk8s$3l4$1@speranza.aioe.org> |
| In-Reply-To | <k1nk8s$3l4$1@speranza.aioe.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:s8YmvdqQ2xYFTHSSvGrml9/6xhkELiZAQozPHDwslHK EwtulhXcAnhjglkekYYlaKFDjUxbSU70WcpBOqM+LOs8sQLIK5 CVbfcGVtw46zXpoCzWJlLrSRVOjpgBdt3lzA6MVOK05Wd8Q5+0 nnQgBqhGDavxwkQeVLAZ+/IOj/ru9BLzk3SRIti4m6L6f2RrOT LsrkfvhBBt6WV/Bcn0AtkG6W2JWTQlQUsozE3fK1Fb7srGO9WW sdgpkoEFD5m9X2v19aGSXZnfeQ8btK0xJr/r8CQmG/16W5jqZL I2xOdtmdpadr6MUsSEilw4/a1QjsVUzCEfDai10prySPHqURQ= = |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | d@davea.name |
| 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.3965.1346329560.4697.python-list@python.org> (permalink) |
| Lines | 42 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1346329560 news.xs4all.nl 6985 [2001:888:2000:d::a6]:34697 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:28107 |
Show key headers only | View raw
On 08/30/2012 07:54 AM, boltar2003@boltar.world wrote:
> Hello
>
> I'm slowly teaching myself python so apologies if this is a dumb question.
> but something has confused me with the os.stat() function:
>
>>>> 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? Its not a dictionary or list or a
> class object as far as I can tell. Thanks for any help.
>
posix.stat_result is a class, and s is an instance of that class. You
can see that by typing type(s).
But you're wondering how print generated all that stuff about the s
instance. You can start to learn that with dir(s), which shows the
available attributes. All those attributes that have leading and
trailing double-underscores are called "special attributes," or "special
methods." In particular notice __str__(), which is a method provided
for your convenience. print will call that if it's available, when you
try to print an instance. It also masquerades as a tuple using
__getitem__() and other special methods.
Normal use of the instance is done by the attributes like s.st_atime
and s.st_size, or by using the object as a tuple. (using the square
brackets to fetch individual items or a range of items)
You can get more documentation directly from s by simply typing
help(s) and/or help(os.stat)
Or you can go to the web docs, http://docs.python.org/library/os.html
and search downward for os.stat (this link is currently for Python 2.7.3)
--
DaveA
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