Beginners question

2012-08-30 Thread boltar2003
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.

B2003

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginners question

2012-08-30 Thread boltar2003
On Thu, 30 Aug 2012 13:14:57 +0100
MRAB  wrote:
>On 30/08/2012 12:54, 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.
>>
>What don't you ask Python? I'm sure you'' get something like this:
>
> >>> type(s)
>

Umm , no I don't.

>>> 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)
>>> type(s) 


Which isn't terrible helpful.

>In other words, it's an instance of the class "stat_result" as defined
>in the file "posix.py".

If its a class , why is it when I create my own class I get a completely
different output with print and type?

>>> 
>>> class foo(object):
.. def __init__(self):
.. pass
.. 
>>> f=foo()
>>> print f
<__main__.foo object at 0xb743956c>
>>> type(f)


B2003

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginners question

2012-08-30 Thread boltar2003
On Thu, 30 Aug 2012 08:25:33 -0400
Dave Angel  wrote:
>You can get more documentation directly from s by simply typing  
>help(s)  and/or  help(os.stat)

I didn't know about help(). Thanks!

B2003


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginners question

2012-08-30 Thread boltar2003
On Thu, 30 Aug 2012 23:06:34 +1000
Chris Angelico  wrote:
>Yep, you're using Python 2. A few things are subtly different. Unless
>you have good reason not to, do consider moving to Python 3; all sorts

Noted. Thanks.

B2003


-- 
http://mail.python.org/mailman/listinfo/python-list