pythontemplate

This is a template for a Python project. It includes several template modules that can form the basis for any Python project.

Steps to follow

These steps are based on Github account dcpetty with private e-mail address dcpetty@users.noreply.github.com and with this repository pythontemplate being copied into repository newpython. Change these to match your account and repository.

Host *
  AddKeysToAgent yes
  UseKeychain yes

Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_dcp
[user]
  name = dcpetty
  email = dcpetty@users.noreply.github.com

Personal access tokens

It is also possible to manage the .git/config url of the newpython local branch with a personal access token (PAT) in lieu of using SSH. This document describes the Github command-line interface in detail.

For this example, with a PAT of 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, the .git/config HTTPS url of the newpython local branch should be changed as follows:

Notes about PATs:

Command-line argument parsing using argparse

argtemplate.py parses example command-line arguments with argparse. argparse allows for command-line argument types of required, optional, flagged, and flagged multiple. Any required and optional command-line arguments must be grouped together either before or after flagged, and flagged multiple command-line arguments which themselves must be grouped together.

Executing argtemplate.py -? from the command line shows:

usage: argtemplate.py [-?] [--version] [-a ARG] [-m MULT] [-v]
                   REQUIRED [OPTIONAL ...]

This is a template that includes argparse.ArgumentParser-style arguments in
all their various forms.

positional arguments:
  REQUIRED              required argument
  OPTIONAL              optional arguments (default: None)

optional arguments:
  -?, --help            show this help message and exit
  --version             show program's version number and exit
  -a ARG, --arg ARG     argument β€” multiples supersede (default: None)
  -m MULT, --mult MULT  multi-argument β€” multiples accumulate (default: None)
  -v, --verbose         echo status information (default: False)

log.py

log.py is a Logging module that logs to the console and a temporary log file.

classtemplate.py

classtemplate.py is a template that demonstrates class and object properties and class and object methods.

Updated .gitignore

The following basic .gitignore prefix is a useful starting point (and includes .git/info/exclude). Add files generated by https://gitignore.io/ to that prefix β€” in this case those for c,c++,jekyll,java,python,r,git,latex,macos,intellij+all,pycharm+all,visualstudiocode.

######################################################################
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
*.[oa]
*~

# IDE files #
#############
*.bluej
*.drjava
*.gpj
*.eml
*.userlibraries
.project
.classpath

# IDE directories #
###################
.settings/
bin/

# User directories #
####################
.git/
.m2/
.gradle/

# Target build directories #
############################
target/
build/
out/

# Compiled source #
###################
*.com

# Packages #
############
*.7z
*.dmg
*.gz
*.iso
*.bz2

# Databases #
#############
*.sql
*.sqlite

πŸ”— permalink and πŸ”© repository for this page.