Getting the date of 7 days ago from current date in python [closed]

import datetime as DT
today = DT.date.today()
week_ago = today - DT.timedelta(days=7)

>>> import datetime
>>> datetime.datetime.now() - datetime.timedelta(days=7)
datetime.datetime(2013, 12, 6, 10, 29, 37, 596779)

If you really just want the date, you can call the date method:

>>> (datetime.datetime.now() - datetime.timedelta(days=7)).date()
datetime.date(2013, 12, 6)

Or, work with dates to begin with as suggested by unutbu.