On Mon, May 13, 2013 at 4:32 PM, Fábio Santos <fabiosantos...@gmail.com> wrote: > > On 13 May 2013 00:22, "Greg Ewing" <greg.ew...@canterbury.ac.nz> wrote: >> The same argument can be applied to: >> >> foo = Foo() >> foo.do_something() >> foo.enable() # should have done this first >> >> You're passing an invalid input to Foo.do_something, >> namely a Foo that hasn't been enabled yet. > > I don't think you can really count that as invalid input in OOP terms. After > all in most languages `self` / `this` / whatever is not an argument to every > method.
Yes, it is; it's just often implicit. C++ lets you poke around with the internals, and it's pretty clear that 'this' is an argument. (See for instance what happens with the gcc 'format' attribute - I can't find a convenient docs page, but it's been mentioned on SO [1] and can be easily verified.) EMCAScript lets you call any function with any 'this' by using the .call() or .apply() methods - which, in my extremely not-humble opinionated opinion, is bad design (closures work implicitly, but the 'this' pointer doesn't??). Python turns an attribute lookup on an instance into an attribute lookup on the class plus a currying. One way or another, the bit-before-the-dot is an argument to the function. [1] http://stackoverflow.com/questions/11621043/how-should-i-properly-use-attribute-format-printf-x-y-inside-a-class ChrisA -- http://mail.python.org/mailman/listinfo/python-list