[BioPython] Some proposed code-cleanup

Jeffrey Chang jchang at jeffchang.com
Fri Jun 20 21:19:54 EDT 2003


Hi Andreas,

I don't understand the subtle differences with UserDict with the dict 
type.  However, it does cause some problems.  For example, if you apply 
the patches to SubsMat/__init__.py and FreqTable.py, the regression 
tests fail!  I don't think we should accept these fixes until we know 
that they won't break current code.

I actually checked in the changes, and had to back them out again.  
Please let me know if I might have missed something, and a module is 
not acting quite right.

I checked in the GenBank patch, except for the snippet:
1140c1131
<             if self._cur_qualifier.key.find(remove_space_key) >= 0:
---
 >             if remove_space_key in self._cur_qualifier.key:

This does not work, because remove_space_key and 
self._cur_qualifier.key are both strings.  The "in" operator does not 
apply.

Jeff



On Thursday, June 19, 2003, at 03:25  AM, Andreas Kuntzagk wrote:

> Hi there,
>
> while surfing the source, I noticed the use of UserDict.UserDict.
> The library-doc discourages the use of this and suggests to inherit 
> from
> the new dict class instead. Since biopython requires python 2.2 this
> should work for everybody.
> So I went and replaced all occurences of UserDict, UserList and
> UserString. All tests working. Should improve readability.
> You find the diffs in diff.out
> More improvement could be done by replacing
>
> a.member = dict()
>
> whith
>
> a.member = {}
>
> What do you think?
>
> Also in GenBank.__init__.py I found the use of 
> "my_dict.has_key(my_key)"
> and "for my_key in my_dict.keys()".
> This can be replaced by "my_key in my_dict" and "for my_key in My_dict"
> GvR did this in Python source (cvs), so this must be a Good Thing(tm)
> :-)
> I'm sure there are other places and I will find them, if people like
> this change.
>
> See GenBank.diff
>
> Andreas
> <diff.out><GenBank.diff>_______________________________________________
> BioPython mailing list  -  BioPython at biopython.org
> http://biopython.org/mailman/listinfo/biopython



More information about the BioPython mailing list