[gt-users] python iterators
Sascha Steinbiss
steinbiss at zbh.uni-hamburg.de
Wed Sep 30 13:59:42 CEST 2009
Hi Brent,
> hi, i've been looking at the python iterators and realized that the
> iterating over featurenodes is not very idiomatic.
This may be true, but we also wanted to preserve interface consistency
across the supported programming languages, so at first we did not put
much effort into fiting the interface to any specific language idioms.
Of course, they are very nice to have anyway ;)
> this is easily fixed by the patch below. it allows:
>
> for feat in FeatureNodeIteratorDepthFirst(node):
> print feat.type
This is much more concise. However, in my opinion, it would be cleaner
to have a traverse() iterator in the FeatureNodeIterator* classes:
dfi = FeatureNodeIteratorDepthFirst(node)
for feat in dfi.traverse():
print feat
This allows the iterator class to be more backward compatible, with no
iteration happening inside the constructor, while still having the
iterator functionality if you want it:
for feat in FeatureNodeIteratorDepthFirst(node).traverse():
print feat
What do you think?
> -brent
Sascha
--
Sascha Steinbiss
Center for Bioinformatics
University of Hamburg
Bundesstr. 43
20146 Hamburg
Germany
Email: steinbiss at zbh.uni-hamburg.de
URL: http://www.zbh.uni-hamburg.de/steinbiss
Phone: +49 (40) 42838 7322
FAX: +49 (40) 42838 7312
More information about the gt-users
mailing list