Re: [Tutor] class variables

2013-12-21 Thread eryksun
On Sat, Dec 21, 2013 at 12:40 PM, Steven D'Aprano wrote: > On Sat, Dec 21, 2013 at 08:41:17AM -0500, eryksun wrote: >> >> >>> vars(type)['__base__'] >> > > Oooh, nice! I always forget about vars(), and end up messing about with > __dict__. It's a bit more efficient to use the __dict__ at

Re: [Tutor] class variables

2013-12-21 Thread Steven D'Aprano
On Sat, Dec 21, 2013 at 08:41:17AM -0500, eryksun wrote: > On Sat, Dec 21, 2013 at 2:14 AM, Steven D'Aprano wrote: > > > > (Sometimes, people will call them "members", especially if they are used > > to C#. The meaning here is member as in an arm or leg, as in > > "dismember", not member in the se

Re: [Tutor] class variables [was Tutor Digest, Vol 118, Issue 99]

2013-12-21 Thread Steven D'Aprano
(I fixed the subject line for you.) On Sat, Dec 21, 2013 at 02:53:28AM -0500, Keith Winston wrote: > On Sat, Dec 21, 2013 at 2:14 AM, wrote: > > > I don't like the terms "class variable" and "instance variable". In the > > Python community, these are usually called class and instance attributes

Re: [Tutor] class variables

2013-12-21 Thread eryksun
On Sat, Dec 21, 2013 at 2:14 AM, Steven D'Aprano wrote: > > (Sometimes, people will call them "members", especially if they are used > to C#. The meaning here is member as in an arm or leg, as in > "dismember", not member in the sense of belonging to a group.) A Python object isn't just a fixed-s

Re: [Tutor] class variables

2013-12-20 Thread Steven D'Aprano
On Fri, Dec 20, 2013 at 02:04:49AM -0500, Keith Winston wrote: > I am a little confused about class variables: I feel like I've repeatedly > seen statements like this: I don't like the terms "class variable" and "instance variable". In the Python community, these are usually called class and inst

Re: [Tutor] class variables

2013-12-20 Thread eryksun
On Fri, Dec 20, 2013 at 5:20 AM, Alan Gauld wrote: > > Similarly if you have a name defined within the instance it will use that if > not it will look in the class. An instance can generally shadow class attributes, except properties and other data descriptors defined by the class are given prece

Re: [Tutor] class variables

2013-12-20 Thread Alan Gauld
On 20/12/13 07:04, Keith Winston wrote: Class.pi == 3.14 # defined/set in the class def instance.pi == 3.14 # initially instance.pi = 4 # oops, changed it Class.pi == 3.14 # still Class.pi = "rhubarb" # oops, there I go again instance.pi == 4 # still Sorry if I'm beating this to a pulp, I

Re: [Tutor] class variables

2013-12-20 Thread Dominik George
Hi, > I am a little confused about class variables: I feel like I've repeatedly > seen statements like this: please take a look at the archives - this topic has been discussed on this list recently. -nik -- * mirabilos is handling my post-1990 smartphone * Aaah, it vibrates! Wherefore art tho

[Tutor] class variables

2013-12-20 Thread Keith Winston
I am a little confused about class variables: I feel like I've repeatedly seen statements like this: There is only one copy of the class variable and when any one object makes a change to a class variable, that change will be seen by all the other instances. Object variables are owned by each indi