Python Data Utils

Gabriel Genellina gagsl-py2 at
Sun Apr 6 09:13:41 CEST 2008

En Sun, 06 Apr 2008 01:43:29 -0300, Jesse Aldridge  
<JesseAldridge at> escribió:

> In an effort to experiment with open source, I put a couple of my
> utility files up <a href="
> tree/master">here</a>.  What do you think?

Some names are a bit obscure - "universify"?
Docstrings would help too, and blank lines, and in general following PEP8  
style guide.
find_string is a much slower version of the find method of string objects,  
same for find_string_last, contains and others.
And I don't see what you gain from things like:
def count( s, sub ):
     return s.count( sub )
it's slower and harder to read (because one has to *know* what S.count  
Other functions may be useful but without even a docstring it's hard to  
tell what they do.
delete_string, as a function, looks like it should delete some string, not  
return a character; I'd use a string constant DELETE_CHAR, or just DEL,  
it's name in ASCII.

In general, None should be compared using `is` instead of `==`, and  
instead of `type(x) is type(0)` or `type(x) == type(0)` I'd use  
`isinstance(x, int)` (unless you use Python 2.1 or older, int, float, str,  
list... are types themselves) is similar - a lot of more or less common things with a different  
name, and a few wheels reinvented :)

Don't feel bad, but I would not use those modules because there is no net  
gain, and even a loss in legibility. If you develop your code alone,  
that's fine, you know what you wrote and can use it whenever you please.  
But for others to use it, it means that they have to learn new ways to say  
the same old thing.

Gabriel Genellina

More information about the Python-list mailing list