Skip to content

Conversation

jdufresne
Copy link
Contributor

No description provided.

@McSinyx
Copy link

McSinyx commented Nov 25, 2018

Funny enough, the entire following snippet

def read(fname):
    inf = open(os.path.join(os.path.dirname(__file__), fname))
    out = "\n" + inf.read().replace("\r\n", "\n")
    inf.close()
    return out

# Do not import `appdirs` yet, lest we import some random version on sys.path.
for line in read("appdirs.py").splitlines():
    if line.startswith("__version__"):
        version = ast.literal_eval(line.split("=", 1)[1].strip())
        break

can be replaced by simply

import re

# TBH I have no idea what does ``lest'' mean
# Do not import `appdirs` yet, lest we import some random version on sys.path.
with open("appdirs.py") as source:
    ast.literal_eval(re.search('^__version__[ \t\f]*=(.*)$', source.read()).group(1))

@pradyunsg
Copy link

I have no idea what does ''lest'' mean

to avoid the risk of, in order to avoid, just in case

@jdufresne jdufresne closed this Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants