class object's attribute is also the instance's attribute?

2012-08-30 Thread
when i write code like this:

class A(object):
 
d = 'it is a doc.'


t = A()

print t.__class__.d
print t.d

the output is same.

so it means class object's attribute is also the instance's attribute. is it 
right? i can not understand it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: class object's attribute is also the instance's attribute?

2012-08-30 Thread
在 2012年8月30日星期四UTC+8下午7时54分35秒,Dave Angel写道:
> On 08/30/2012 06:55 AM, 陈伟 wrote:
> 
> > when i write code like this:
> 
> >
> 
> > class A(object):
> 
> >  
> 
> > d = 'it is a doc.'
> 
> > 
> 
> >
> 
> > t = A()
> 
> >
> 
> > print t.__class__.d
> 
> > print t.d
> 
> >
> 
> > the output is same.
> 
> >
> 
> > so it means class object's attribute is also the instance's attribute. is 
> > it right? i can not understand it.
> 
> 
> 
> In your example, you have no instance attribute.  So when you use the
> 
> syntax to fetch one, the interpreter looks first at the instance,
> 
> doesn't find it, then looks in the class, and does.  That is documented
> 
> behavior.  Some people use it to provide a kind of default value for
> 
> instances, which can be useful if most instances need the same value,
> 
> but a few want to overrride it.
> 
> 
> 
> -- 
> 
> 
> 
> DaveA
thank you very much.

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


what is the difference between st_ctime and st_mtime one is the time of last change and the other is the time of last modification, but i can not understand what is the difference between 'change' and

2012-09-28 Thread

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