Skip to main content

Count Letters

count-letters is a simple Python package for counting characters that appear only once in a text.

The package can be used from the command line or directly in Python code.

Features

  • Count unique characters in a string
  • Read text from a UTF-8 file
  • Use the package from the command line
  • Use the package in Python code
  • Supports Python 3.10 and newer

Requirements

  • Python 3.10 or newer

Installation

Install the package from PyPI:

pip install count-letters

Command Line Usage

After installation, the count-letters command is available.

Count characters in a string

count-letters --string "hello"

Short version:

count-letters -s "hello"

Output:

3

The characters h, e, and o appear only once, so the result is 3.

Count characters from a file

Create a UTF-8 text file, for example text.txt:

hello

Run:

count-letters --file text.txt

or:

count-letters -f text.txt

Output:

3

Using both arguments

If --file and --string are used together, --file has priority.

count-letters --string "error" --file text.txt

In this case, the program reads and processes the content of text.txt.

File errors

If the specified file does not exist, the program shows an error message:

count-letters --file missing.txt
error: Файл не знайдено

Using as a Python Package

You can also use the package directly in Python code:

from count_letters.collection import count_unique_letters

result = count_unique_letters("hello")
print(result)

Output:

3

To read text from a file:

from count_letters.collection import open_and_read_file

text = open_and_read_file("text.txt")
print(text)

Help

To see all available command-line options:

count-letters --help

Development

Install the project and development dependencies:

uv sync

Run tests:

uv run pytest

Run code checks:

uv run ruff check .
uv run ruff format --check .
uv run mypy count_letters tests

Build

Build the package with:

uv build

The built package files will be created in the dist directory.

Download files

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

Source Distribution

count_letters-0.1.0.tar.gz (46.1 kB view details)

Uploaded Source

Built Distribution

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

count_letters-0.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: count_letters-0.1.0.tar.gz
  • Upload date:
  • Size: 46.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for count_letters-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fca4cf84a671253d47f6ea8e547554c608c6dd11503a5c42826262dd7879901e
MD5 f719e2128e86d22d108daafeb34ef31d
BLAKE2b-256 d449d23b0930c1c203464f2e190baabb7103764c325cfc6fe85d99bc87ed5b16

See more details on using hashes here.

File details

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

File metadata

  • Download URL: count_letters-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for count_letters-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4d8b34630557d5defa647ff92aada56c0bc8f4e37cfde7da37d775ac185144c
MD5 3550b5dd887fbd586890eba59f9cdaa9
BLAKE2b-256 466e9dd1bcd5b71238d5c67f3936f43dd46ca57ae4ccadd10e0395289c55e20b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page