r/learnpython • • Mar 25 '25

TIL Python recommends you use snake_case instead of camelCase for variables

0 Upvotes

Apologies if this is a "low quality" post or something frequently brought up, but thought I'd share in the spirit of shared learning.

I started off programming in VB, Java, C++ and the convention I was taught/saw everyone using was camelCase.

As I've dipped my toe further into Python and started looking into the actual code of my favorite libraries on Github, I noticed that they were all using snake_case whenever possible. Upon further research, it seems PEP8 advocates for snake_case (unless for backward compatability).

I'm sure smarter people than me have argued over which is more readable (snake_case vs camelCase) so I won't chime in on this. To me, this is just a convention and it's more important to pick whatever works best for your purposes (i.e. if you're going to be contributing to open source Python projects, maybe stick with snake_case).

In the same vein, I also have been reading a bit about spaces between equal signs and variables in declarations vs use in arguments suffice to say that is a separate topics.