On Feb 12, 11:13 am, Steven D'Aprano <steve +comp.lang.pyt...@pearwood.info> wrote: > On Fri, 11 Feb 2011 10:15:27 -0800, Dan Stromberg wrote: > > I'd use a class rather than a dictionary - because with a class, pylint > > (and perhaps PyChecker and pyflakes?) should be able to detect typos > > upfront. > > *Some* typos. Certainly not all. > > The more complex the code -- and with 100 or so parameters, this sounds > pretty damn complex -- there is a non-negligible risk of mistakenly using > the wrong name. Unless pylint now has a "do what I mean, not what I say" > mode, it can't save you from typos like this: > > params.employerID = 23 > params.employeeID = 42 > # much later > if params.employeeID == 23: > # Oops, I meant employ*er*ID > ... > > > With a dictionary, typos remain runtime timebombs. > > Are your unit tests broken? You should fix that and not rely on just > pylint to detect bugs. Unit tests will help protect you against many more > bugs than just typos. > > Besides, and I quote... > > "I find it amusing when novice programmers believe their main job is > preventing programs from crashing. ... More experienced programmers > realize that correct code is great, code that crashes could use > improvement, but incorrect code that doesn't crash is a horrible > nightmare." -- Chris Smith > > -- > Steven
The 100+ parameters just means "everything" can be adjusted outside of the code, invariable most of it isn't. I am setting this up with some bayesian calibration in mind. A lot of those parameters will be switches as well. I think perhaps I will write a defaults module and just read a .INI file with the values the user wants changing. Originally I was just going to read everything in, but maybe this is better from a usage point of view. As I said I am happy to consider a dictionary, although some of the calculations are quite complex and I *think* it is easier to read this way, rather than with a dictionary. That is purely an opinion, I don't have a computer science background and so I am asking really, is what I am doing very bad, and if so why? What do other people do? I have tried to search a lot on this subject but I find the example not very specific, (or I am reading the wrong places). thanks. -- http://mail.python.org/mailman/listinfo/python-list