Write a Python Module / Package

Refer: https://stackoverflow.com/questions/15746675/how-to-write-a-python-module-package

Python 3 - UPDATED 18th November 2015

Found the accepted answer useful, yet wished to expand on several points for the benefit of others based on my own experiences.

Module: A module is a file containing Python definitions and statements. The file name is the module name with the suffix .py appended.

Module Example: Assume we have a single python script in the current directory, here I am calling it mymodule.py

The file mymodule.py contains the following code:

def myfunc():
print("Hello!")
If we run the python3 interpreter from the current directory, we can import and run the function myfunc in the following different ways (you would typically just choose one of the following):

>>> import mymodule
>>> mymodule.myfunc()
Hello!
>>> from mymodule import myfunc
>>> myfunc()
Hello!
>>> from mymodule import *
>>> myfunc()
Hello!
Ok, so that was easy enough.

Now assume you have the need to put this module into its own dedicated folder to provide a module namespace, instead of just running it ad-hoc from the current working directory. This is where it is worth explaining the concept of a package.

Package: Packages are a way of structuring Python’s module namespace by using “dotted module names”. For example, the module name A.B designates a submodule named B in a package named A. Just like the use of modules saves the authors of different modules from having to worry about each other’s global variable names, the use of dotted module names saves the authors of multi-module packages like NumPy or the Python Imaging Library from having to worry about each other’s module names.

Package Example: Let's now assume we have the following folder and files. Here, mymodule.py is identical to before, and __init__.py is an empty file:

.
└── mypackage
├── __init__.py
└── mymodule.py
The __init__.py files are required to make Python treat the directories as containing packages. For further information, please see the Modules documentation link provided later on.

Our current working directory is one level above the ordinary folder called mypackage

$ ls
mypackage
If we run the python3 interpreter now, we can import and run the module mymodule.py containing the required function myfunc in the following different ways (you would typically just choose one of the following):

>>> import mypackage
>>> from mypackage import mymodule
>>> mymodule.myfunc()
Hello!
>>> import mypackage.mymodule
>>> mypackage.mymodule.myfunc()
Hello!
>>> from mypackage import mymodule
>>> mymodule.myfunc()
Hello!
>>> from mypackage.mymodule import myfunc
>>> myfunc()
Hello!
>>> from mypackage.mymodule import *
>>> myfunc()
Hello!
Assuming Python 3, there is excellent documentation at: Modules

In terms of naming conventions for packages and modules, the general guidelines are given in PEP-0008 - please see Package and Module Names

Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.

Turn off video auto play in Firefox

Refer: https://support.mozilla.org/en-US/questions/1222694

about:config?filter=autoplay

Helpful Reply
The pref that controls auto-play has been changed in the current Firefox release (63.0.1) to an Integer value.

media.autoplay.default = 0

When the first two prefs listed below (or at least user-gestures-needed) are true then there is also a setting available in "Options/Preferences -> Privacy & Security -> Permissions" and you can inspect and modify the exceptions.

media.autoplay.enabled.user-gestures-needed = true
media.autoplay.ask-permission = true
media.autoplay.default = 0 [0=Allowed, 1=Blocked, 2=Prompt]
You can open the about:config page via the location/address bar. You can accept the warning and click "I accept the risk!" to continue.

http://kb.mozillazine.org/about:config
See also:
https://support.mozilla.org/en-US/kb/block-autoplay

CLI – Command Line Tools

Refer: https://zeroturnaround.com/rebellabs/5-command-line-tools-you-should-be-using/

icdiff - Meld replacement for the command line

Refer: https://www.jefftk.com/icdiff

Cannot View PNG

Problem viewing a PNG, could be the new WebP format from Google.

On Ubuntu you can use gThumb or XnView

Review: https://itsfoss.com/webp-ubuntu-linux/

 

ZZU City Codes in POLAR

From: "Harris, Tyrone (HA Group)"
Subject: Gateway codes
Date: January 22, 2018 at 3:15:47 PM PST

ZZU is still a valid code for Polar. It is a code that was made up by the business to reflect US booking online without conflicting with any regional promotions. Canada is ZZC

DAIR is the Polar command to see the air codes built in Polar.

Git Cert Error

Use the following to accept a self-signed certificate:

$ git config --global http.sslVerify false

Refer: https://confluence.atlassian.com/fishkb/unable-to-clone-git-repository-due-to-self-signed-certificate-376838977.html

Using Trello

Refer: https://webapps.stackexchange.com/questions/45616/trello-how-do-i-find-all-the-cards-archived-when-on-a-particular-list

Finding Archived Items:
is:archived

Finding Archived Items and in a list:
is:archived list:Done