Add readlines_generator.

voussoir 2023-12-31 14:16:06 -08:00
parent 5a76734072
commit acaabb7d61
1 changed files with 9 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import glob
import os
import re
import shutil
import typing
_glob = glob
@ -440,6 +441,14 @@ class Path:
with, **kwargs) as handle:
return handle.readlines()
def readlines_generator(self, mode, **kwargs) -> typing.Generator:
Shortcut function for opening the file handle and reading lines from it
as a generator instead of a list.
with, **kwargs) as handle:
yield from handle
def relative_path(self):
return self.relative_to(cwd())