(Un-)conventions

OK, let’s get this out of the way: I’m coming to Python late in my career and I’m coming over to this side after years of programming in languages like JavaScript, PHP, C & C++, Java, Modula-2, Pascal, Forth, and Assembly. And yes, I may have some quirks and habits that have built up some crud over the years.

Where am I going with this? Well, let’s just say that my coding style may not always be Pythonic. But, in my defense, I try very hard to be consistent both within and across my projects 🤓

Naming conventions

  • Class namesCamel case with first letter always capitalized – example: Email, Twitter, etc. The only exception are classes where a common acronym works best as a class name (e.g. SMS) and then I use all caps.

  • Function and method namesSnake case – example: send_message(). Private class methods are always prefixed with an underscore (_).

  • Variable namesCamel case with occasional pseudo hungarian notation. I know … this is so not Pythonic! But I can’t help it. Most of my variables have names like authToken and fromName and names of private class attributes are, again, prefixed with an underscore (_). But yes, sometimes you may see a few names like listStr to indicate that this is a list of str. Usually I only use names like that inside helper functions where, like in this example, the strings can contain anything (e.g. names of dogs, auth tokens, tags, etc.). At least I have stopped calling them “arrays” 🤓

  • Constants – always all caps – ‘nuff said! 😉

Files and folders

  • Root folder – holds misc config files, etc. for git, Poetry, and other tools.

  • docs folder – holds most documentation in .rst files. The exceptions are files like README.rst, LICENSE.rst and other more generic project documentation which are stored in the root folder.

  • src folder – holds all source code files.

  • tests folder – holds all test files.

Other notes

Again, I try to be very consistent, and my code should (hopefully) be easy to follow. I also try to document a lot of stuff, both with in-code comments and actual project documentation. Why? Because I have the memory of a goldfish 1 and I forget why I did whatever I did after a week or so.

Now, I am a one-person band, and there are bound to be mistakes and, quite likely, a bug or two (or more) in my code and documentation. However, I am dogfooding my packages and libraries as I use them in my various projects, and I try to fix bugs and correct mistakes as I find them.

And, as always, if you find a problem, please feel free to log an issue. Or, better yet, maybe you can help fix the issue and submit a PR 🤓

1

Turns out goldfish may have better memory than me: Do goldfish really have a 3-second memory?