[Novalug] Learning Python ???

Stuart Gathman stuart@gathman.org
Sat Mar 23 22:31:00 EDT 2013


Long ago, Nostradamus foresaw that on 03/23/2013 11:13 AM, Kevin Cole
would write:
>
> Methods are excuses for madness and a type of acting. Madness can have
> a method. Objects cannot. Do you say "My car has methods?" Would any
> native English speaker understand if you did?
>
>
A car does have methods, and an interface.  An interface is a standard
set of methods.  For a car, there are two basic standard interfaces:
Auto and Stick.   Both include steering wheel, accelerator, gear shift,
ignition, and brake methods.  The Stick interface adds the clutch
method, which in conjunction with the gear shift provides lower level
control.

Cars comes in many implementations.  But all the cars that implement the
Auto interface can be driven by anyone with a license (the Stick
interface requires more skill).  Even cars with radically different
implementations (electric or hybrid) have the same interface.

So, for instance, python has a "file" interface that includes read,
write, and close methods.  objects that implement that interface are
called "file" objects.  Even when the implementation has no relation to
the system "file" object.  A huge amount of code works with any kind of
"file" object.



More information about the Novalug mailing list