Jon Olav Vik <jonovik <at> gmail.com> writes:

> I'm particularly puzzled by the following (can be run after the code below). 
> Note that t[0] is a Table object.
> 
> In [74]: for row in t[0]: print row
>    ....:
> (0, 100.0)
> (3, 103.0)
> (6, 106.0)
> (9, 109.0)
> 
> In [75]: [row for row in t[0]]
> Out[75]: [(9, 109.0), (9, 109.0), (9, 109.0), (9, 109.0)]
> In [77]: a, b, c, d = [row for row in t[0]]
> 
> In [78]: a is b
> Out[78]: True
> 
> In [79]: b is c
> Out[79]: True
> 
> I thought that a list comprehension and explicit for loop were mostly 
> equivalent. However, it seems that the Row class is a slippery creature...

One more try: fails to sort, but at least includes all rows.
In [41]: [row for row in heapq.merge(*[ti.read() for ti in t])]
Out[41]:
[(0, 100.0),
 (3, 103.0),
 (1, 101.0),
 (2, 102.0),
 (6, 106.0),
 (4, 104.0),
 (5, 105.0),
 (9, 109.0),
 (7, 107.0),
 (8, 108.0)]

I suspect I'm missing something.

Jon Olav



------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to