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

Reply via email to