with open('/etc/apt/sources.list', 'r') as sources:
    lines = sources.readlines()
with open('/etc/apt/sources.list', 'w') as sources:
    for line in lines:
        sources.write(re.sub('^# deb', 'deb', line))
Как сделать sed как текст заменить на python?