Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,7 @@
with open('xxx.txt') as f:
for i, line in enumerate(f):
if i == 6:
break
else:
print('Not 7 lines in file')
line = None

View file

@ -0,0 +1,7 @@
from itertools import islice
with open('xxx.txt') as f:
try:
line = next(islice(f, 6, 7))
except StopIteration:
print('Not 7 lines in file')

View file

@ -0,0 +1 @@
print open('xxx.txt').readlines()[:7][-1]

View file

@ -1,6 +0,0 @@
from itertools import islice
with open('xxx.txt') as f:
linelist = list(islice(f, 7, 8))
assert linelist != [], 'Not 7 lines in file'
line = linelist[0]