Pretty tough to beat Alan Gauld, but the more examples the merrier for
me, and the infogami has plenty of those. Thanks.
http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm
rpd
--
http://mail.python.org/mailman/listinfo/python-list
John Salerno wrote:
> Couldn't we also say that this issue of namespace scope is a little more
> specific to Python than OOP in general? I could very easily be wrong,
> but I wouldn't want the poster to think that this is how OOP works always.
No, the confusion in the OP was between class attrib
[EMAIL PROTECTED] wrote:
> Thanks guys,
>
> It is starting to make much more sense. Most documentation I find about
> OO is very academic
Couldn't we also say that this issue of namespace scope is a little more
specific to Python than OOP in general? I could very easily be wrong,
but I wouldn't
[EMAIL PROTECTED] wrote:
> It is starting to make much more sense. Most documentation I find about
> OO is very academic
you may find Jay Parlar's new python class tutorial helpful:
http://parlar.infogami.com/pytut_classes_copy
(this is a proposed addition/replacement for the class chapter
Thanks guys,
It is starting to make much more sense. Most documentation I find about
OO is very academic
--
http://mail.python.org/mailman/listinfo/python-list
J Rice wrote:
> Someone should correct me if I'm wrong but:
> If
> you want to change myVar for the whole class, you need to reference it
> as self.myVar.
>
wrong: If you want to change myVar for the whole *class*, you need to
reference it as Obj.myVar (prefix with classname).
self.myVar will c
On 2006-04-13, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I just started with Python and I am new to OO programming.
> Here is a simple code:
> "
> class Obj:
> myVar = 1
>
> def __init__(self):
> myVar = 2
>
> #
>
>
> myObj = Obj()
>
> print myObj.myVar
> "
>
Someone should correct me if I'm wrong but:
If you add "print myVar" to __init__, you will see that myVar is
assigned to "2" in that function. It doesn't change the assignment of
"1" in the class because myVar in __init__ is local to __init__. If
you want to change myVar for the whole class, yo
[EMAIL PROTECTED] wrote:
> Hi,
>
> I just started with Python and I am new to OO programming.
> Here is a simple code:
> "
> class Obj:
> myVar = 1
>
> def __init__(self):
> myVar = 2
>
> #
>
>
> myObj = Obj()
>
> print myObj.myVar
> "
>
> The output is of this scri
Hi,
I just started with Python and I am new to OO programming.
Here is a simple code:
"
class Obj:
myVar = 1
def __init__(self):
myVar = 2
#
myObj = Obj()
print myObj.myVar
"
The output is of this script is '1'. I would except it to be '2'.
I not understanding
10 matches
Mail list logo