[Tutor] Re: How to accomplish Dict setdefault(key, (append to existing value list) or (start new list) )?
Jeff Kowalczyk
jtk@yahoo.com
Thu May 15 15:09:12 2003
I found the surprise, the dictionary key for a date in that format
gives strange behavior.
>>> print OrderDates.get('2003-05-14',[])
None
This works:
>>> print OrderDates.get('20030514',[])
[]
as does
>>> print OrderDates.get(r'2003-05-14',[])
[]
What is happening there? Is the string evaluated or tested for
hashability somehow? What are the rules?
Can you suggest a raw-evaluation syntax for the key in the
one-line get(k,[]) version of your example. If it isn't the
CCYY-MM-DD format, its going to be some other kind of
delimiter...