Magic function

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri Jan 11 19:15:44 EST 2008


On Fri, 11 Jan 2008 08:29:18 -0800, dg.google.groups wrote:

> Hi all,
> 
> I'm part of a small team writing a Python package for a scientific
> computing project. The idea is to make it easy to use for relatively
> inexperienced programmers. 

...

> This is fine, but we decided that for clarity of these programs, and to
> make it easier for inexperienced programmers, we would like to be able
> to write something like:
> 
> obj1 = Obj(params1)
> obj2 = Obj(params2)
> ...
> run()
> 
> The idea is that the run() function inspects the stack, and looks for
> object which are instances of class Obj, creates a Bigobj with those
> objects and calls its run() method.
> 
> So, any comments on that approach?

Your users are *scientists*, and you don't trust their intellectual 
ability to learn a programming language as simple as Python?

Instead of spending time and effort writing, debugging  and maintaining 
such a fragile approach, why not invest in a couple of introductory books 
on Python programming and require your scientists to go through the first 
few chapters? Or write out a one-page "cheat sheet" showing them simple 
examples. Or, and probably most effectively, make sure all your classes 
have doc strings with lots of examples, and teach them how to use help().

Some people problems are best dealt with by a technical solution, and 
some are not.



-- 
Steven



More information about the Python-list mailing list