Skip to content

Update install.py

Rodrigo Muino Tomonari requested to merge github/fork/Avinash-Raj/patch-1 into master

-> Why I have changed s = re.sub(r'#.*?\n', '', s) to s = re.sub(r'#.*\n?', '', s)?

Because your regex won't match the comment line which exists at the last (End of a file) because it expects a newline character . But s = re.sub(r'#.*\n?', '', s) should remove all the comment lines irrespective of their locations. .*? -> .* because dot by default won't match line breaks.

-> A simple string.replace should do this re.sub(r'\'', '"', s) job, you don't need to go for `re.sub

If you want to further reduce these two lines of code into a single line then go with this,

re.sub(r"#.*\n?|(')", lambda x: '"' if x.group(1) else '', s)

Merge request reports

Loading