Date manipulation and Java 'interface' equivalents

Darrell Gallion darrell at
Mon Nov 6 00:34:40 CET 2000

From: "Martin Christensen":
> First of all, I am doing some statistics with a PostgreSQL database,
> and for this I need to manipulate some dates, ie. add a week to this
> date or subtract a month from another. I didn't find any obvious
> candidates for this kind of date math in the library reference. Now,
> _of course_ this can be done in Python rather than forcing me to use
> the DBMS for this, but... erm... how?
Check out mxDateTime

> Second question: is there a Python equivalent of Java interfaces?

Yes, but not the same.
I'm not a Java expert, but I believe interfaces provide a compile time
Allows the Java compiler to validate a call and all of it's type info. Much
like pure abstract base classes in C++.

Refugees from those authoritarian languages have to unlearn the rigid

These two classes share a common interface and could be used in some cases
where a file pointer is expected.
But A().read() will produce AttributeError:

class A:
    def write(self, s):
        print "A:", s

class B:
    def write(self, s):
        print "B:", s

Found a couple hits on


More information about the Python-list mailing list