Skip to main content

Because common sense is not so common. Now it is — in Python!

Project description

🤯 common-sense

Build Status Made with ❤️ Python Version

This library prevents you from doing stupid things (sometimes).

Installation

pip install common-sense

Quick Usage

from common_sense import *

# Dates
is_weekend(datetime.date.today())
days_until(datetime.date(2025, 12, 31))
pretty_date(datetime.date.today())
next_weekday('Monday')

# Debug
why_none(None)
why_empty([])
why_false(False)
explain_type(42)

# Philosophy
wisdom()
sarcastic('I love bugs')
shrug('It failed')
future_truth()
agree('Python is awesome')
disagree('Monday is the best')

# Life
should_sleep(datetime.time(23, 0))
should_eat(13)
caffeine_needed(0)
hydration_reminder()

# Strings
slugify('Hello World!')
humanize_number(1000)
camel_to_snake('CamelCase')
truncate('Hello world', 5)

# Numbers
safe_divide(10, 0)
percent(2, 8)
clamp(5, 1, 10)
is_prime(7)

# Utils
flatten([[1,2],[3,4]])
unique([1,2,2,3])
chunk([1,2,3,4,5], 2)
first([1,2,3])
last([1,2,3])

Why?

Because common sense is not so common. Now it is — in Python!


Fun Notes

  • 100+ witty helpers and one-liners.
  • "If it works, don’t touch it."
  • "Don’t argue with code — it always wins."
  • "This library prevents you from doing stupid things (sometimes)."

Testing

pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

common_sense-0.1.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

common_sense-0.1.0-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file common_sense-0.1.0.tar.gz.

File metadata

  • Download URL: common_sense-0.1.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for common_sense-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b73e4cf117d6dd14ec1963f54b736e52a55dd420525698f2ed20f99b9807402b
MD5 b983b217bbeeb19d272c3b1df9525ca0
BLAKE2b-256 2dc97598c44e3b8b29b8f36ddf27a86a4af1c08417ccf4fb92403c90e8183048

See more details on using hashes here.

File details

Details for the file common_sense-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: common_sense-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for common_sense-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1af5e48f79f9e1882f7956db38ec804c05ab22ce50b5e1cc6ad9b0395be6e2c
MD5 074dceecc63ed5e7cebb7e82a12474cf
BLAKE2b-256 e17f1f75429a93550e940fcd852788dd0093a6bfec5e551271a5a7f453d9e270

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page