Created
July 21, 2025 06:44
-
-
Save wonderbeyond/033a9adad331ddcff64d058e8b7c74c0 to your computer and use it in GitHub Desktop.
[python] Locate line match some pattern in file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Help me implement the Python function, | |
def locate_line(filename, pattern: str, after: str|None, until: str|None) -> int: ... | |
It finds the first line in file matching the re pattern and returns the 1-based lineno, 0 means nothing found. The after and until params specify the optional searching range. | |
Please write concise, clear but readable code. | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment