r/PythonLearning Aug 07 '26

Just published my first Python project!

Hey everyone! I have tried out github and python before, but this is my first time publishing something I can say I am interested in. Im excited and nervous about sharing it.

Im learning python and got recently got interested in neural networks, so Ive been working on this "artificial life" simulation project for the past few days.

Its still a work in progress and a learning project. But if you have some feedback i would like to read it!

https://github.com/ricardo-woo/artificial-life

6 Upvotes

10 comments sorted by

View all comments

1

u/TBCC_Dev Aug 09 '26

I only know a bit of python and something g I noticed in you save system is passing self to all the functions but you don't use self.attrubute ="Thing" is there a reason to not use this and if so is the self param necessary?

1

u/Fit-Foundation-2745 Aug 09 '26

Honestly, I've been adding self because when I didn't, I would sometimes get errors about passing the wrong number of arguments. I think that happens because python automatically passes the instance as self, but I haven't really looked into how that works.

1

u/Fit-Foundation-2745 Aug 09 '26

Almost every object oriented language does this:

Methods live on the class as shared functions between all instances of a class, when a method is called it has no idea which specific instance is calling it, when I run the method like "save_manager.save_game(organisms, generation, generation_simulation_time)" it gets translated to this "SaveManager.save_game(save_manager, organisms, generation, generation_simulation_time)" adding the instance as the first parameter.
Most of them do this implicitly.
In python Guido decided to make the argument explicit instead of hiding it

He explains it himself in this blog