pre-PEP generic objects

Istvan Albert ialbert at mailblocks.com
Fri Dec 3 08:58:48 EST 2004


Steven Bethard wrote:

 > The question is not how easy it is to write,
 > but how many times it's going to get written.

but with that logic we could  create a standard
"looping" construct called loop(x) that would stand in for

for i in range(x):

or a file_reader('whatever') generator that would be
a shortcut for:

for line in file('whatever'):
    line  = line.strip()
    elems = line.split()

 > and more than one of them had rewritten the class a few times.

Two observations regarding that:

1. Probably not entirely true. They might have used something like a Bunch
but it is a bit too optimistic to believe that they could have directly used
your Bunch. My Bunches turn out to be just a ever so slightly different.
Either have an update operation or an equality, or can be hashed etc.
So in the end it might save a lot less work.

2. Even if it was, no big deal. It takes too little time to do it.

On the other hand, it would be nice to have a module that
implements various design patterns. The Bunch, the Borg, the Null,
the Proxy all nicely documented tucked away in their separate
module. That would feel a lot less like littering the standard name space
with an class that just "seems"  to be useful.

just an opinion.

Istvan





More information about the Python-list mailing list