Re: answers.py v0.0.1 - source

2006-12-28 Thread Pyenos
#!/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

Re: answers.py v0.0.1 - source

2006-12-28 Thread bearophileHUGS
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,

Re: answers.py v0.0.1 - source

2006-12-28 Thread Peter Otten
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,

Re: answers.py v0.0.1 - source

2006-12-28 Thread Marc 'BlackJack' Rintsch
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

answers.py v0.0.1 - source

2006-12-28 Thread Pyenos
#!/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