Newbie needs "interface"

Richard Brodie R.Brodie at
Thu Nov 22 17:57:30 CET 2001

"Roberto Bonato" <rbonato at> wrote in message news:3BFD2536.7B4AFFC6 at

> Sometimes I want the results to be written on the stdout,
> sometimes on a Tkinter Text widget, sometimes to a file. I feel the need
> of something like a Java Interface with a method "write" to wrap all
> such devices into.

A Java interface is a 'promise' to implement a method. In Python, just
make classes with a write method.

Trivial example:

class T:
    def write(self, input):
        sys.stdout.write('DEBUG-->' + input)

t = T()
print >> t, (1,2),

DEBUG-->(1, 2)

More information about the Python-list mailing list