June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,7 +1,10 @@
>>> marker, line = '#', 'apples, pears # and bananas'
>>> line[:line.index(marker)].strip()
'apples, pears'
>>>
>>> marker, line = ';', ' apples, pears ; and bananas'
>>> line[:line.index(marker)].strip()
'apples, pears'
def remove_comments(line, sep):
for s in sep:
i = line.find(s)
if i >= 0:
line = line[:i]
return line.strip()
# test
print remove_comments('apples ; pears # and bananas', ';#')
print remove_comments('apples ; pears # and bananas', '!')

View file

@ -1,8 +1,5 @@
def remove_comments(line, sep):
for s in sep:
line = line.split(s)[0]
return line.strip()
import re
# test
print remove_comments('apples ; pears # and bananas', ';#')
print remove_comments('apples ; pears # and bananas', '!')
m = re.match(r'^([^#]*)#(.*)$', line)
if m: # The line contains a hash / comment
line = m.group(1)