Skip to content

A collection of utility functions that I found myself writing over and over again across different projects.

License

Notifications You must be signed in to change notification settings

trldp/trldp-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trldp-utils

A collection of utility functions that I found myself writing over and over again across different projects. Instead of duplicating code, I've extracted these into a reusable module.

Overview

This repository contains commonly-used helper functions for:

  • Interactive user prompts with yes/no questions
  • Human-readable list joining

Installation

Add this repository as a Git submodule in your project:

git submodule add https://github.com/trldp/trldp-utils.git trldp_utils

No pypi package is available yet.

Usage

Importing as a Submodule

Once added as a submodule, you can import the utilities directly:

import trldp_utils

trldp_utils.ask_yes_no()

Ask the user a yes/no question and get a boolean response:

import trldp_utils

if trldp_utils.ask_yes_no("Do you want to continue?"):
    print("User said yes!")
else:
    print("User said no!")

hjoin()

Join a list of strings into a natural, human-readable format:

import trldp_utils

print(trldp_utils.hjoin(['apple', 'banana'])) #Output: 'apple and banana'
print(trldp_utils.hjoin(['apple', 'banana', 'cherry'])) #Output: 'apple, banana and cherry'
print(trldp_utils.hjoin(['a', 'b', 'c', 'd'], max_items=2)) #Output: 'a, b and 2 others'

See docs/api.md for the full API documentation.

Contributing

This small project is open-source and welcomes all contributions. Please use GitHub pull requests to propose any changes and the GitHub issues page to report any issue.

License

All code in this repository is licensed under GPL-3+, see here for more information.

About

A collection of utility functions that I found myself writing over and over again across different projects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages