Thoughts on some stdlib modules

"Martin v. Löwis" martin at v.loewis.de
Sat Apr 9 07:37:47 EDT 2005


vegetax wrote:
> Why does people have to put wrappers around about half of the standart
> library modules? i have wrappers for urllib,urllib2, [... many more ...]
> 
> I mean is this normal?

Not sure what "this" is :-) Is it normal that people write wrappers
around libraries? Yes, most certainly so. I see people writing wrappers
around the C++ library, around Java collection classes (*), around .NET
classes, ... essentially for every library that somebody writes,
somebody else will write a wrapper - unless the library is useless.

Is it normal that *you* write this many wrappers? I don't know you
good enough to answer that question :-)

Is it good that people write these wrappers? I don't think so. Is it
the library's fault? I don't think so, either. People write these
wrappers because they cannot remember how to use the library. This
is not because the library is hard to remember, but because people
cannot remember much at all - except for the things they have done
themselves (**). So they write a library wrapper, and doing so takes
them enough time to ingrain their own API into their own memory.
If somebody else wrote the very same wrapper for them, they still
would not like to use it.

So what can be done? Not much, I think - no matter what the
library reorganization is, people will continue to write wrappers
around it. That is not to say that a library reorganization couldn't
be helpful to some people - if people find enough energy, a library
reorganization will happen. Some will like it, some will hate it.

I personally try to avoid library wrappers like the plague. It makes
my code harder to write, but easier to read.

Regards,
Martin

(*) Just look at the Apache Commons library. People write wrappers
for stuff like

  bool isEmptyString(String s){
   return s==null || s.length()==0;
  }

(**) of course, most people can only remember a subset of these,
as well.



More information about the Python-list mailing list