html tags and python
Patrik Andreasen
pan at botong.org
Sat Mar 26 06:38:27 EST 2005
Hansan wrote:
> Hi.
>
> Yeah I also like just to be able to write in numbers.
> That is how it works right now.
>
> But then I will have to make some code, that validates if the day number is
> higher than allowed.
> Like if it is January, the days arnt allowed to be higher than 31.
>
> Will one be so kind and explain how I write that code:
Just use the datetime module:
Python 2.4.1a0 (#2, Mar 1 2005, 15:45:39)
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import date
>>> date(2004, 2, 29)
datetime.date(2004, 2, 29)
>>> date(2005, 2, 29)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: day is out of range for month
>>>
/patrik
More information about the Python-list
mailing list