I am a newbie python developer and I have a question.
I have a python script check if updates are available on an external webpage but I got stuck while trying to get it to override old file with new one. What the code does below is get new.py and open it as a txt file. It then searches for __VERSION__
. My code for searching for new version is below. How would I replace current.py with new.py?
__VERSION__ = '1.0'
#Get new version
new_version = ''
with open('new.py') as newfile:
for line in newfile:
line = line.strip()
if '__VERSION__' in line:
_, new_version = line.split('=', maxsplit=1)
new_version = new_version.strip()
break
Thanks @user:6530979 Can anyone help me understand what to do after this? EDIT: The goal is for current.py to override its self with new.py’s code Any help will be appreciated!!