#!/usr/bin/python
# answers.py --- A simple answer-bot.
# Copyright 2006 Logan Lee
#
# RELEASE NOTES:
#
# - I have fixed an error where the program crashes on query of
#+unknown string to answers dictionary.
# - Rephrased 'Do you h
Marc 'BlackJack' Rintsch:
You give lot of comments and I agree with most of them.
> One idiom to solve this is:
> def __init__(self, answers=None):
> self.answers = answers or dict()
I suggest to avoid such usage of or/and (expecially for newbies), that
is triky and can produce bugs,
Marc 'BlackJack' Rintsch wrote:
> > def __init__(self,answers={}):
> > self.answers=answers
>
> Default arguments are only evaluated once when the ``def`` is executed,
> so all your `Storage` classes share the same dictionary. One idiom to
> solve this is:
>
> def __init__(self,
In <[EMAIL PROTECTED]>, Pyenos wrote:
> global ANSWER_PATH
``global`` at module level has no effect. That keyword is used to declare
names in functions or methods global that would be local to the function
otherwise and it's only needed if you want to *assign* to the global name
from within a fu
#!/usr/bin/python
# answers.py --- A simple answer bot
# Copyright (C) 2006 Logan Lee
#
# MESSAGE:
#
# This program is a simple text-console program
#+that asks for a problem and its solution then
#+persists the problem-solution dictionary to