Hi, On 25 November 2010 09:09, Francesc Alted <fal...@pytables.org> wrote: > Yes, the behaviour in PyTables is the expected one (and it is document > correctly too). I think the reason for this was some lazyness on my part: I > wanted to share the code between the `read()` method and `iterrows()`. That > being said, I agree that it would be better if `iterrows()` would expose > your suggested behaviour.
I see; array.read(12345) is the same as array.read(start=12345) and that's why stop=start+1... I missed that piece of documentation, it says "If you only want to iterate over a given range of rows in the array, you may use the start, stop and step parameters, which have the same meaning as in Array.read()" and clearly I didn't read on to that one. > However, I'm not sure if we should change the current behaviour because that > may broke some existing code. In fact, my vote would go for keeping > backwards compatibility. What others think? I agree that it's better to keep a sub-optimal solution than to break backwards compatibility, unless the major version changes (Pytables 3? :P). I just realised that stop=-1 does not do what I want, because the 'last' value is not inclusive, e.g.: In [16]: tbl.nrows Out[16]: 9410977 In [17]: it = tbl.iterrows(start=9410975, stop=-1) In [18]: it.next() Out[18]: /collocations.row (Row), pointing to row #9410975 In [19]: it.next() --------------------------------------------------------------------------- StopIteration Traceback (most recent call last) /storage4/home/gerrit/<ipython console> in <module>() /storage4/home/gerrit/.local/lib/python2.6/site-packages/tables/tableExtension.so in tables.tableExtension.Row.__next__ (tables/tableExtension.c:7462)() /storage4/home/gerrit/.local/lib/python2.6/site-packages/tables/tableExtension.so in tables.tableExtension.Row.__next__general (tables/tableExtension.c:8492)() /storage4/home/gerrit/.local/lib/python2.6/site-packages/tables/tableExtension.so in tables.tableExtension.Row._finish_riterator (tables/tableExtension.c:8641)() StopIteration: what I want is stop=tbl.nrows: In [20]: it = tbl.iterrows(start=9410975, stop=tbl.nrows) In [21]: it.next() Out[21]: /collocations.row (Row), pointing to row #9410975 In [22]: it.next() Out[22]: /collocations.row (Row), pointing to row #9410976 I agree that it's a bad idea to break backward-compatibility. stop=tbl.nrows works. I'm thinking if it might be nice to have a magic value, stop=0 or stop=inf or stop="never", but that's probably not very Pythonic. > At any rate, can you file a ticket so that we don't forget about this? I will do that on the weekend. Gerrit. -- Gerrit Holl PhD student at Department of Space Science, Luleå University of Technology, Kiruna, Sweden http://www.sat.ltu.se/members/gerrit/ ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Pytables-users mailing list Pytables-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pytables-users