[Tutor] Help with understanding classes

Lowell Tackett lowelltackett at yahoo.com
Sun May 22 18:04:26 CEST 2011


Robert...I am similarly where you are stuck, a beginner with little insight, so my perspective might have some draw to it.  Try this on for size - while watching a friend stencil Christmas decorations on living room windows last year, it dawned on me that a class is quite simply - a stencil.

While using a "Santa Claus" stencil, I watched my friend employ different features in different places; a Santa Claus here, some reindeer there, a few pine bows in another spot, and each with different colored spray paint...and the light bulb came on.  Each different "thing" she stenciled was an "instance" of the class (stencil) "Santa Claus".

For me, that was the magic moment.  Very unprofessional, I'm sure, but, hey, so what?!

>From the virtual desk of Lowell Tackett  


--- On Sat, 5/21/11, Robert Sjöblom <robert.sjoblom at gmail.com> wrote:


From: Robert Sjöblom <robert.sjoblom at gmail.com>
Subject: [Tutor] Help with understanding classes
To: "tutor at python.org" <tutor at python.org>
Date: Saturday, May 21, 2011, 6:24 AM


I'm trying to wrap my head around classes and their attributes, but am having a hard time doing so. The websites and books that I have consulted haven't been much help; most of them assume prior programming/oop experience, something I lack. 

>From what I understand it's a "blueprint", so each time you instantiate it you run whatever's in the __self__ part is assigned to the instance. What I'm wondering is how to access and change attributes in the instance (whatever it might be; a list, a specific value, a string...).

I just can't seem to grasp the concept or syntax very well, and none of the sources I've found go to great lengths explaining them to someone as thick-headed as me. So if anyone could take the time to explain, or point me to sources to read, I'd be grateful

Thanks in advance, and best regards,
Robert S. 
Sent from my iPhone
_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list