On 13 May 2013 00:22, "Greg Ewing" <greg.ew...@canterbury.ac.nz> wrote: > > Wayne Werner wrote: >> >> On Fri, 10 May 2013, Gregory Ewing wrote: >> >>> f = open("myfile.dat") >>> f.close() >>> data = f.read() >> >> >> To clarify - you don't want a class that has functions that need to be called in a certain order with *valid input* in order to not crash. >> >> Exactly what does happen - a ValueError is raised because you're(*) passing self into the file.read() function, and that input is invalid > > > 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. > > > -- > Greg > -- > http://mail.python.org/mailman/listinfo/python-list
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.
-- http://mail.python.org/mailman/listinfo/python-list