Skip to content

Latest commit

 

History

History
150 lines (104 loc) · 5.9 KB

README.md

File metadata and controls

150 lines (104 loc) · 5.9 KB

This file is part of eRCaGuy_hello_world: https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world

Pages

  1. TODO.md
  2. pandas_README.md
  3. zmq_README.md - ZeroMQ (ZMQ) notes

See also

  1. The generic form (specific version numbers removed from the URLs) of the official links at the end of the official installer window when installing Python in Windows, from the official .exe Python installer here:
    1. Official Python tutorial: https://docs.python.org/3/tutorial/index.html
    2. Official Python documentation: https://docs.python.org/3/index.html
    3. What's new in Python: https://docs.python.org/3/whatsnew/
    4. Official documentation on "Using Python on Windows": https://docs.python.org/3/using/windows.html

Notes

  1. wip means "work-in-progress".
  2. To learn about private variables which begin with a single underscore _, internal Python variables which begin with two underscores __, class variables which are shared among all instances of a class, instance variables, which are generally prefixed with self. in a class, and __slots__, which are a special way to store instance variables in a list inside your object instead of in a dict inside your object, see: slots_practice/slots_practice.py.

Plotting and browser-based GUIs in Python

TODO: LEARN THIS!:

I'd like to learn how to do plotting in a GUI in a browser. Here are some tools to look at:

Two 3rd-party libraries to do most of the work:

  1. Plotly: https://plotly.com/python/ - manages everything graphs-related.
    1. Here's the page that talks about the specifics of graphing using Pandas DataFrames: https://plotly.com/python/plot-data-from-csv/
      1. See also near the bottom of the page where it says, "What About Dash?"
  2. Dash: https://dash.plotly.com/ - manages everything GUI-related.

Pylint linter and static code analyzer for Python

linting: pylint

  1. Source code on GitHub: https://github.com/PyCQA/pylint
  2. Pylint User Manual: https://pylint.pycqa.org/en/latest/

Use this linter to check your Python code for errors.

Installation instructions

See my answer here: Ask Ubuntu: Installing Pylint for Python3 on Ubuntu

New instructions:

See: https://github.com/PyCQA/pylint#install

pip3 install pylint
# upgrade to the latest version; see: https://stackoverflow.com/a/47071257/4561887
pip3 install pylint --upgrade

Old instructions:

pylint versions before 2.0.0 or so had separate executables for Python2 vs Python3 code. In the old versions, pylint was for Python2 and pylint3 was for Python3. As of version 2.0.0 or so, we are back to one executable named pylint, and it handles only Python3 code. To get this latest version from the GitHub releases page, do this:

  1. Go to the "Releases" page for pylint on GitHub, and download the source code for the latest release (ex: v2.12.2).
  2. In your file manager, right-click on the downloaded file and go to "Extract Here". This will produce a directory named pylint-2.12.2, for instance.
  3. cd into the extracted directory and run the setup.py script; ex:
    cd path/to/pylint-2.12.2
    sudo python3 setup.py install
    See also: https://github.com/PyCQA/pylint#install
  4. Check your version and ensure it now says pylint 2.12.2
    pylint --version

Run pylint

  1. Check your version:
    pylint --version
  2. Lint some code:
    pylint path/to/my_python3_file.py

Sample usage command and output. Notice it does show the Convention and Warning codes (ex: C0301 and W0105), which is great!:

eRCaGuy_hello_world/python$ pylint hello_world.py  
************* Module hello_world  
hello_world.py:4:0: C0301: Line too long (102/100) (line-too-long)
hello_world.py:33:0: C0116: Missing function or method docstring (missing-function-docstring)
hello_world.py:49:-1: W0105: String statement has no effect (pointless-string-statement)

-----------------------------------
Your code has been rated at 4.00/10

List of all error codes

pylint output shows these 5 types of messages (emphasis added):
Source: Tutorial: https://pylint.pycqa.org/en/latest/tutorial.html.

Output:
Using the default text output, the message format is :
MESSAGE_TYPE: LINE_NUM:[OBJECT:] MESSAGE
There are 5 kind of message types :

  • (C) convention, for programming standard violation
  • (R) refactor, for bad code smell
  • (W) warning, for python specific problems
  • (E) error, for probable bugs in the code
  • (F) fatal, if an error occurred which prevented pylint from doing further processing.

>> For a list of all error codes, such as C0301, C0116, W0105, etc., see here: https://pylint.pycqa.org/en/latest/messages/messages_list.html <<

Disable pylint errors

See here: https://pylint.pycqa.org/en/latest/user_guide/message-control.html

Examples:

  1. Disable a violation on the given line using # pylint: disable=whatever at the end of the offending line: From hello_world.py:
    """
    SAMPLE OUTPUT:
    
        eRCaGuy_hello_world/python$ ./hello_world.py
        Hello world!
    
    """ # pylint: disable=pointless-string-statement
  2. [MY PREFERENCE] Disable a violation on the next line using # pylint: disable-next=whatever just before the offending line: From hello_world.py:
    # pylint: disable-next=pointless-string-statement
    """
    SAMPLE OUTPUT:
    
        eRCaGuy_hello_world/python$ ./hello_world.py
        Hello world!
    
    """