Sfoglia il codice sorgente

refactor load_list

quarrying 4 anni fa
parent
commit
cc8d1624c3
1 ha cambiato i file con 2 aggiunte e 4 eliminazioni
  1. 2 4
      khandy/utils_file_io.py

+ 2 - 4
khandy/utils_file_io.py

@@ -2,10 +2,9 @@ import json
 from collections import OrderedDict
 
 
-def load_list(filename, encoding='utf-8', start=0, stop=None, step=1):
+def load_list(filename, encoding='utf-8', start=0, stop=None):
     assert isinstance(start, int) and start >= 0
     assert (stop is None) or (isinstance(stop, int) and stop > start)
-    assert isinstance(step, int) and step >= 1
     
     lines = []
     with open(filename, 'r', encoding=encoding) as f:
@@ -14,8 +13,7 @@ def load_list(filename, encoding='utf-8', start=0, stop=None, step=1):
         for k, line in enumerate(f):
             if (stop is not None) and (k + start > stop):
                 break
-            if k % step == 0:
-                lines.append(line.rstrip())
+            lines.append(line.rstrip('\n'))
     return lines