[SciPy-dev] A quote of some relevance from Guido

Travis Oliphant oliphant at ee.byu.edu
Fri Oct 21 20:19:31 EDT 2005


I just picked up this little tidbit from python-dev.  It is a useful concept to keep in mind.


--------------------------------------------------
The "Swiss Army Knife (...Not)" API design pattern
--------------------------------------------------

This fortnight saw a number of different discussions on what Guido's  
guiding principles are in making design decisions about Python. Guido  
introduced the "Swiss Army Knife (...Not)" API design pattern, which  
has been lauded by some as `the long-lost 20th principle from the Zen  
of Python`_. A direct quote from Guido:

     [I]nstead of a single "swiss-army-knife" function with various  
options that choose different behavior variants, it's better to have  
different dedicated functions for each of the major functionality types.

This principle is the basis for pairs like str.split() and str.rsplit 
() or str.find() and str.rfind().  The goal is to keep cognitive  
overhead down by associating with each use case a single function  
with a minimal number of parameters.




More information about the SciPy-Dev mailing list