[Tutor] time comparison question

Gonçalo Rodrigues op73418 at mail.telepac.pt
Fri Nov 26 13:50:01 CET 2004


Brian van den Broek wrote:
> Hi all,

[text snip]

> 2) Naturally, these worries lead me to think that there must be a
> better way. I took a brief look at the datetime module, thinking it
> was a natural place to find such tools. But it is all in terms of
> classes. Sadly, I am still not too comfortable with doing things via
> OOP, so I'd prefer a procedural (if that's the right term for a
> program with functions but no classes) way. Is there a cleaner,
> non-class employing, way of meeting my goal of finding out if a date
> of the form YYYY-MM-DD is in the future, present, or past? (If it
> matters, I am on Windows.)
> 

Spend a little time with the datetime module. Really, it will save you a
lot of trouble. And you don't have to do OO by using it, or at least not
more than you are *already* doing in Python - everything in Python is an
object that has a class, etc. Think of the classes in datetime module as
you think of the builtin classes like list, tuple, etc. You just use
them, they do not force you to program in procedural or in OO or in
the-whatever way.

With my best regards,
G. Rodrigues


More information about the Tutor mailing list