Editing My Python Coding Conventions
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
= Coding Conventions Etc. = | = Coding Conventions Etc. = | ||
− | In reading my code it may be of some use to know what conventions I have ( tried ) to follow. The code has been developed over quite a period of time so the standards are not uniform. What I write here are the standards that are in quite a bit of the code and the directions that I am trying to move. In all of the coding consistency is an important standard, I have a ways to go. I am now only coding in Python 3.6 or up. Here are some types of conventions. Ultimately if you want to understand the code, read it. I work hard to make it readable, so please try, you can let me know of shortcoming, but note that I am aware of the fact that it still need improvement | + | In reading my code it may be of some use to know what conventions I have ( tried ) to follow. The code has been developed over quite a period of time so the standards are not uniform. What I write here are the standards that are in quite a bit of the code and the directions that I am trying to move. In all of the coding consistency is an important standard, I have a ways to go. I am now only coding in Python 3.6 or up. Here are some types of conventions. Ultimately if you want to understand the code, read it. I work hard to make it readable, so please try, you can let me know of shortcoming, but note that I am aware of the fact that it still need improvement. |
== Names == | == Names == | ||
− | I try to be consistent: this is good but have not been very successful in standards: I keep changing my mind. I am avoiding short names and try to make names descriptive enough that they are somewhat self documenting. References are often copied across objects for easy access ( lots of parameters for example ); when this happens the name of the object is generally ( should be always ) the same in both objects | + | I try to be consistent: this is good but have not been very successful in standards: I keep changing my mind. I am avoiding short names and try to make names descriptive enough that they are somewhat self documenting. References are often copied across objects for easy access ( lots of parameters for example ); when this happens the name of the object is generally ( should be always ) the same in both objects. |
== Formatting == | == Formatting == | ||
Nothing special here but I like white space and use a lot. This is not standard Python. But this is what I like. | Nothing special here but I like white space and use a lot. This is not standard Python. But this is what I like. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Docstrings == | == Docstrings == | ||
− | I am working towards using them but have not arrived at a format that I both like to read and which is quick enough to write. Not good as of | + | I am working towards using them but have not arrived at a format that I both like to read and which is quick enough to write. Not good as of 2017 Jan |
− | |||
== Imports == | == Imports == | ||
Line 54: | Line 41: | ||
I am moving toward using __ and _ as prefixes for more private methods, but have not gone too far in this direction. | I am moving toward using __ and _ as prefixes for more private methods, but have not gone too far in this direction. | ||
− | = Application Structure = | + | == Application Structure == |
+ | coming... | ||
+ | |||
=== MVC Structure === | === MVC Structure === | ||
− | I try to separate the Model, View, and Controller into separate modules and classes. The View is the class GUI | + | I try to separate the Model, View, and Controller into separate modules and classes. The View is the class GUI. |
=== GUI Structure === | === GUI Structure === | ||
− | + | coming... | |
− | *Construct frame by frame in a subroutine | + | *Construct frame by frame in a subroutine returning the frame reference, the caller then places the frame. Typically constructed and placed from top to bottom from left to right. |
− | *Elements | + | *Elements: |
** Buttons for application management: restart the app, edit the parameters, edit the log, help. | ** Buttons for application management: restart the app, edit the parameters, edit the log, help. | ||
− | ** Buttons.... for | + | ** Buttons.... for the application. |
− | + | ** A text control for application messages, sort of a mini console for the application. | |
− | ** A | ||
=== Application Parameters === | === Application Parameters === | ||
Line 73: | Line 61: | ||
=== Typical Application Functionality === | === Typical Application Functionality === | ||
− | + | coming... | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== MultiThreading === | === MultiThreading === | ||
Line 95: | Line 73: | ||
I usually implement the standard python logging utility, messages into a file configured by parameters.py, the gui typically has a button to view this file. | I usually implement the standard python logging utility, messages into a file configured by parameters.py, the gui typically has a button to view this file. | ||
− | = Links = | + | == Links == |
− | = | + | |
− | + | ||
− | |||
− | |||
− | |||
− | |||
*[[Configuration Files For Python]] | *[[Configuration Files For Python]] | ||
− | * | + | *[[Configuration Files For Python]] |
− | + | ||
− | + | [[Category:Python SmartPlug]][[Category:Python]] |