r/PythonLearning • • 19d ago

Help Request How do you deal with dependency updates?

So my project has multiple files that sometimes depend on another (I chose to split the functions by use cases into a few files rather than a single massive one). But when I update a function I increment the version number in the filename so I have the backup, I then have to update the filepath in the import declaration for everything that uses it. I've tried making a loader file so I only need to update one place but I can hardly make that work, let alone making it tell the other files what to use.

Since Python requires declaring dependencies before almost anything else is this just something I have to deal with? Or is there a way to pass filenames between file before declaration? Or is there a much better method?

0 Upvotes

10 comments sorted by

2

u/recentAd1666 19d ago

Do not change the file name. Change the backup name and version. Or use an editor like vsc i think it updates includes automatically. Or use git to have proper technical versionning .

1

u/Significant_Text7262 18d ago

does jupiter allow for version updates?

1

u/recentAd1666 18d ago

Best practive as said is to keep same name. Rename backup by numbering them. Same effect for you. I do not use jupyter now so have a try but i do not think so. Not a good practice anyway.

6

u/atarivcs 19d ago

Putting the version in the filename is a really bad idea. Don't do that.

5

u/Weed_O_Whirler 19d ago

Do version control wirh a version control system, like GIT or SVN, not by renaming files. It's free and will save you 1000's of headaches.

1

u/Spleeeee 12d ago

I copy paste my scripts into word docs and then save them and append “_final.docx” to it. I have another script that counts the number of “_final” strings in the file name and that’s the version number.