Use Python instead of sed