@SnoopJeDi/

UncomfortableHarshFlashdrives

Python

No description

fork
loading
Files
  • main.py
  • data.txt

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.32870342990181567","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"c2VhcmNoID0gImNvbnZhbGxpcyIgICMgc29tZSBzdWJzdHJpbmcgd2UncmUgc2VhcmNoaW5nIGZvcgplbmQgPSAiRU5EIgoKd2l0aCBvcGVuKCdkYXRhLnR4dCcsICdyJykgYXMgZjoKICBpdCA9IGl0ZXIoZikgICMgZXhwbGljaXRseSBjcmVhdGUgYW4gaXRlcmF0b3IKICAjIGFkdmFuY2UgdGhlIGl0ZXJhdG9yIHRvIHRoZSBzdGFydCBwb3NpdGlvbgogIG5leHQobGluZSBmb3IgbGluZSBpbiBpdCBpZiBzZWFyY2ggaW4gbGluZS5sb3dlcigpKSAgCgogICMgbm93LCBpdGVyYXRpbmcgd2lsbCBzdGFydCBmcm9tIHdoZXJlIHdlIGxlZnQgb2ZmIGFib3ZlLCBhbmQgYWxsIHdlCiAgIyBoYXZlIHRvIHRyYWNrIGlzIHdoZW4gdG8gZW5kIHRoZSBpdGVyYXRpb24gYnkgY2hlY2tpbmcgZm9yIHRoZSBlbmQgc3Vic3RyaW5nCiAgZm9yIGxpbmUgaW4gaXQ6CiAgICBpZiBlbmQgaW4gbGluZTogICMgbm8gbG93ZXIoKSBoZXJlIGJlY2F1c2Ugd2UncmUgcXVpdGUgc3VyZSB0aGF0IHRoZSBlbmQgc2VudGluZWwgaXMgKmV4YWN0bHkqICJFTkQiCiAgICAgIGJyZWFrCiAgICBlbHNlOgogICAgICBwcmludChsaW5lKQo="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
search = "convallis"  # some substring we're searching for
end = "END"

with open('data.txt', 'r') as f:
  it = iter(f)  # explicitly create an iterator
  # advance the iterator to the start position
  next(line for line in it if search in line.lower())  

  # now, iterating will start from where we left off above, and all we
  # have to track is when to end the iteration by checking for the end substring
  for line in it:
    if end in line:  # no lower() here because we're quite sure that the end sentinel is *exactly* "END"
      break
    else:
      print(line)