-
Notifications
You must be signed in to change notification settings - Fork 0
Quirks
Some quirks of the coding style
I use this module to change my path because of the way source is laid out on my machines. It also make some modules in sub-directories loadable with just their module name. Probably best to keep it of only modify with care
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.
I find it more readable, may or may not blacken in future.
-- I need to explain....
Often used when not necessary because makes extension of string to multi-line string easy.
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,
Why:
May be used to prevent name collisions: a_str not str for a variable
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.
This creates an outline heading in Spyder. It is great for code navigation. # ---- tof for top of file # ---- eof for end of file.
This seems to come, in part, with QT programming, but these long modules often come with multiple classes that are all loaded at the same time Separate classes gives name space isolation. The outline comments in Spyder make navigation easy. I have not yet found a reason to break them up.
Use to keep code style tools quite and used when I think the method name, arguments, and code are self explanatory enough.
Have not seen the cost benefit being favorable. My try letting simulated intelligence take a try at it. If the cost were low enough I would do it.
I just have not figured out how to do it especially since so many things happen primarily in the GUI. Not sure there is a favorable cost/benefit. Want to show me how?
These quirks tend to lead to low scores in linting. Additionally the Spyder linter seems unable to validate the imports from qtpy. My adjust_path.py trick also makes imports un-findable by the linter.
We slowly move out dead or commented out code. Some of the commented out code may stay a long time for debugging. Methods that end in xxx are on their way out. Methods that end in _old or _bak are also on the way out, but we are not in a hurry.
- !! marks code that "must" be revisited.
- ?? marks questions to think about when we have time