[Tutor] Adding key, value to Dictionary
Emile van Sebille
emile at fenx.com
Fri Mar 27 19:46:05 CET 2009
David wrote:
> greg whittier wrote:
>> On Fri, Mar 27, 2009 at 1:31 PM, David <david at abbottdavid.com> wrote:
>>> But I can not get this to update after the first time it is ran.
>>>
>>> def get_todo():
Other common ways this is done include:
def get_todo(todo={}):
...
This works well if one copy is to be used the entire time the
application is live, although it's also often cited as a gotcha...
and
def get_todo(todo=None):
if todo==None:
todo = {}
...
Both the above allow you to pass in a starting todo dict, so you could
juggle multiple todo dicts...
HTH,
Emile
More information about the Tutor
mailing list