Hello,
When I make a list with list comprehensions, I get what I believe are
incorrect results. I made a short example that shows what I'm talking
about. I'm not sure if this is a bug in the iterator, or if this behavior
is by design.
Thanks,
Craig
***************************************************
import tables, random
class Example(tables.IsDescription):
col1 = tables.Int32Col(pos=1)
col2 = tables.Int32Col(pos=2)
hFile = tables.openFile('test.h5', 'w')
table = hFile.createTable('/', 'table', Example)
entry = table.row
for i in range(40):
entry['col1'] = random.randint(0, 5)
entry['col2'] = random.randint(0, 5)
entry.append()
table.flush()
for i in table.where('col1 == 2'):
print i
"""gave:
(2, 5)
(2, 4)
(2, 4)
(2, 5)
(2, 0)
that is fine
"""
l = [i for i in table.where('col1 == 2')]
print l
"""gave:
[(5, 2), (5, 2), (5, 2), (5, 2), (5, 2)]
that is no good
"""
cond = table.where('col1 == 2')
l = [i for i in cond]
print l
"""gave:
[(5, 2), (5, 2), (5, 2), (5, 2), (5, 2)]
that is also no good
"""
print cond
""" and this gave:
(5, 2)
this is really unexpected (for me)
"""
hFile.close()
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Pytables-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pytables-users