[Tutor] Append a dictionary value
Sander Sweers
sander.sweers at gmail.com
Sun Apr 5 01:34:37 CEST 2009
2009/4/4 David <david at abbottdavid.com>:
> I put together a todo program here;
> http://linuxcrazy.pastebin.com/f74beaf78
>
> And I am trying to add an option to edit the values which are date and time.
> Below I have gotten this far but now I need some help. looks like my attempt
> to use setdefault will not work. Please point me in the right direction my
> head has started to hurt :)
I do not understand what it is you want to do. Do you want to replace
the old date and time with the new? If so you already do this with
todo[answer] = datevalue, time. Why do you want to use setdefault?
> #!/usr/bin/python
> import time
> import datetime
> todo = {'Study Python':
> (datetime.date(2009, 4, 1), datetime.time(12, 15)),
> 'Clean House':
> (datetime.date(2009, 4, 4), datetime.time(15, 15)),
> 'Fix Python Code':
> (datetime.date(2009, 3, 29), datetime.time(9, 1))}
Why not use a datetime object?
todo = {'Study Python':
(datetime.datetime(2009, 4, 1,12,15)}
Greets
Sander
More information about the Tutor
mailing list