Operating on an iPhone here... Apologies for terseness. The list comp is not equivalent to the for loop. It eliminates anything with no .py on the end. That's not what we want: consider runtest.py blast_test.Blast_Test as an example broken case. --- C. Titus Brown, c...@msu.edu
On May 29, 2009, at 8:37 PM, Christopher Lee <l...@chem.ucla.edu> wrote: > > Hi Titus, > here's what it generates in the pygr/tests directory: > >>>> import os >>>> l = os.listdir('.') >>>> l > ['.gitignore', '.pygr_data', 'barfoo', 'blast_test.py', > 'blast_test.pyc', 'COMMENTS', 'data', 'doctests_test.py', > 'doctests_test.pyc', 'formatdb.log', 'graph_test.py', > 'graph_test.pyc', 'metabase_test.py', 'metabase_test.pyc', > 'nlmsa_test.py', 'nlmsa_test.pyc', 'oldtests', 'pygrdata2_test.pyc', > 'pygrdata_test.py', 'pygrdata_test.pyc', 'README.txt', 'runtest.py', > 'seqdb_test.py', 'seqdb_test.pyc', 'sequence_test.py', > 'sequence_test.pyc', 'skipme', 'sqlsequence_test.py', > 'sqlsequence_test.pyc', 'sqltable_test.py', 'sqltable_test.pyc', > 'tempdir', 'test.gz', 'testlib', 'tools', 'webserve-info.db', > 'webserve-info.db-journal', 'worldbase_test.py', 'worldbase_test.pyc'] >>>> m = [t[:-3] for t in l if t.endswith('.py')] >>>> m > ['blast_test', 'doctests_test', 'graph_test', 'metabase_test', > 'nlmsa_test', 'pygrdata_test', 'runtest', 'seqdb_test', > 'sequence_test', 'sqlsequence_test', 'sqltable_test', > 'worldbase_test'] > > > On May 29, 2009, at 5:22 PM, C. Titus Brown wrote: > >> >> Could you check that that works equivalently to my code, first? >> >> (Try 'x', 'xy', and 'x.py' as list elements.) > >>>> l = ['x', 'xy', 'x.py'] >>>> m = [t[:-3] for t in l if t.endswith('.py')] >>>> m > ['x'] > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pygr-dev" group. To post to this group, send email to pygr-dev@googlegroups.com To unsubscribe from this group, send email to pygr-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pygr-dev?hl=en -~----------~----~----~----~------~----~------~--~---