Re: why is "self" used in OO-Python?

2008-07-15 Thread Fredrik Lundh
ssecorp wrote: def append(self, item): self.stack.append(item) I can get to see the stack with var.stack but then why even implement append when I could do self.stack.append(x) etc. That way you could do away with OO completely. Umm. Even if you were to write that, self and stack

Re: why is "self" used in OO-Python?

2008-07-13 Thread satoru
On Jul 13, 12:32 am, ssecorp <[EMAIL PROTECTED]> wrote: > I first learned about OO from Java. > > I much prefer to program in Python though. > > However I am consufed about 2 things. > > 1. Why do I have to pass self into every method in a class? Since I am > always doing why cant this be automated

Re: why is "self" used in OO-Python?

2008-07-12 Thread ssecorp
On Jul 12, 8:44 pm, castironpi <[EMAIL PROTECTED]> wrote: > On Jul 12, 1:01 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > > > > > ssecorp <[EMAIL PROTECTED]> wrote: > > > 1. Why do I have to pass self into every method in a class? Since I am > > > always doing why cant this be automated or abstract

Re: why is "self" used in OO-Python?

2008-07-12 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Duncan Booth <[EMAIL PROTECTED]> wrote: > Sadly a lot of Java programmers mistake the limitations of their language > for rules of OO programming, and worse this has spread from Java into other > languages where these restrictions no longer need apply. You can g

Re: why is "self" used in OO-Python?

2008-07-12 Thread castironpi
On Jul 12, 1:01 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > ssecorp <[EMAIL PROTECTED]> wrote: > > 1. Why do I have to pass self into every method in a class? Since I am > > always doing why cant this be automated or abstracted away? > > Are the instances where I won't pass self? > > I imagine th

Re: why is "self" used in OO-Python?

2008-07-12 Thread [EMAIL PROTECTED]
On 12 juil, 18:32, ssecorp <[EMAIL PROTECTED]> wrote: > I first learned about OO from Java. > > I much prefer to program in Python though. > > However I am consufed about 2 things. > > 1. Why do I have to pass self into every method in a class? You mean "declare self as the first argument", I assu

Re: why is "self" used in OO-Python?

2008-07-12 Thread Duncan Booth
ssecorp <[EMAIL PROTECTED]> wrote: > 1. Why do I have to pass self into every method in a class? Since I am > always doing why cant this be automated or abstracted away? > Are the instances where I won't pass self? > I imagine there is some tradeoff involved otherwise it would have been > done awa

Re: why is "self" used in OO-Python?

2008-07-12 Thread Carl Banks
On Jul 12, 12:32 pm, ssecorp <[EMAIL PROTECTED]> wrote: > I first learned about OO from Java. > > I much prefer to program in Python though. > > However I am consufed about 2 things. Short answer is, "Java isn't the only way OOP." Longer answers follow. > 1. Why do I have to pass self into ever

why is "self" used in OO-Python?

2008-07-12 Thread ssecorp
I first learned about OO from Java. I much prefer to program in Python though. However I am consufed about 2 things. 1. Why do I have to pass self into every method in a class? Since I am always doing why cant this be automated or abstracted away? Are the instances where I won't pass self? I ima