Skip to content
russ_hensel edited this page May 13, 2026 · 5 revisions

Some quirks of the coding style

adjust_path.py

I use this module to change my path because of the way source is laid out on my machines. It normally will have no effect on you. Feel free to empty the file if you do not like its contents

if name == "main": usage

At the top of most files. In development running of most file will result in the whole app being run by means of main.py This means you do not have to navigate to main.py to run.

Lots of white space, equal sign and other code column alignment

I find it more readable, may or may not blacken in future.

Cast instance variable to locals

-- I need to explain....

Parenthesis around strings

Often used when not necessary because makes extension of string to multi-line string easy.

unnecessary local variables

as in

msg       = ( "some message" )
print( msg )

Why:

  • can assist in debug
  • helps keep lines short
  • may be more readable
  • if local is used multiple times actually speeds code ( does no slow down )
  • typos are caught in locals but not instance var.
  • often used: msg, widget, sql, db,

Prefix a_

Why:

May be used to prevent name collisions: a_str not str for a variable

Looping with index

I normally use ix for the numerical index in a loop. If looping over a list of names, I might use "i_name in names" with enumerate both of them.

Code to revistit

  • !! marks code that "must" be revisited.
  • ?? marks questions to think about when we have time

Clone this wiki locally