Skip to main content

A simple greeting library with repeat functionality

Project description

HelloNexus

A simple yet powerful greeting library with repeat functionality.

Installation

python -m pip install hellonexus

Quick Start

from hellonexus import hellonexus as hn

# Print "Hello, World!" once
hn.say()

# Print "Hello, World!" 5 times
hn.say(5)

# Print with custom message
from hellonexus.hellonexus import HelloNexus

nexus = HelloNexus("Welcome to Nexus!")
nexus.say(3)

Features

  • Repeat functionality - Print greetings 1-indexed times
  • Flexible input - Accepts integers or strings as repeat count
  • Keyboard Interrupt handling - Graceful Ctrl+C handling
  • EOF handling - Graceful EOF (Ctrl+D) handling
  • Call counter - Track how many times you've greeted
  • Custom messages - Personalize your greetings
  • Module-level functions - Quick and easy usage
  • Class-based design - Object-oriented approach
  • Type hints - Better IDE support and code quality
  • Unit tested - Comprehensive test coverage

Why choose HelloNexus?

Feature HelloNexus Other HelloWorld programs
Repeat functionality
1-indexed counting
Keyboard interrupt handling ⚠️
EOF handling
Call counter
Custom messages
Type hints ⚠️
Unit tests
Module-level functions
Object-oriented design ⚠️
String repeat support
Graceful error handling

Usage Examples

Basic Usage

from hellonexus import hellonexus as hn

# Single greeting
hn.say()  # Output: 1: Hello, World!

# Multiple greetings
hn.say(3)  # Output: 1: Hello, World!
           #         2: Hello, World!
           #         3: Hello, World!

Using Strings as Input

hn.say("4")  # Works with string numbers too!

Custom Messages

from hellonexus.hellonexus import HelloNexus

nexus = HelloNexus("Welcome to the Nexus!")
nexus.say(2)
# Output:
# 1: Welcome to the Nexus!
# 2: Welcome to the Nexus!

Tracking Calls

nexus = HelloNexus()
nexus.say(3)
print(nexus.get_call_count())  # Output: 3

nexus.reset()  # Reset counter to 0
print(nexus.get_call_count())  # Output: 0

Graceful Interrupt Handling

nexus = HelloNexus("Press Ctrl+C to stop")
nexus.say(100)  # Press Ctrl+C to interrupt gracefully
# Output: [Interrupted] Goodbye from HelloNexus!

API Reference

HelloNexus Class

__init__(default_message: str = "Hello, World!")

Create a new HelloNexus instance with optional custom message.

say(repeat: Optional[Union[int, str]] = None) -> None

Print the greeting message, optionally repeated.

  • repeat=None: Prints once
  • repeat=int: Prints that many times
  • repeat=str: Converts to int and prints that many times
  • Raises ValueError for invalid values

get_call_count() -> int

Returns the total number of successful say() calls.

reset() -> None

Resets the call counter to 0.

Module-Level Function

say(repeat: Optional[Union[int, str]] = None) -> None

Convenience function that uses a global HelloNexus instance.

Error Handling

HelloNexus handles errors gracefully:

# Invalid repeat values raise ValueError
hn.say("invalid")  # ValueError: Invalid repeat value: 'invalid'. Must be a number.
hn.say(0)          # ValueError: Repeat must be positive, got 0
hn.say(-5)         # ValueError: Repeat must be positive, got -5
hn.say([1,2,3])    # TypeError: Repeat must be int, str, or None, got list

Development

Run Tests

python -m pytest tests/

Run Examples

python examples/basic_usage.py

License

MIT License - Copyright (c) 2026 Light Bulb Experiments

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

hellonexus-1.0.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

hellonexus-1.0.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file hellonexus-1.0.0.tar.gz.

File metadata

  • Download URL: hellonexus-1.0.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for hellonexus-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1b4e6c615198585326632e6bd3f14e0ca2436e931f46c95138acab5a37ee9357
MD5 93a40b6cf6b4db429da627d2ba188f00
BLAKE2b-256 e168ab68c247cf0c9530396a46696d70a911b10c961d2dfe64b53d1b826da56e

See more details on using hashes here.

File details

Details for the file hellonexus-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: hellonexus-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for hellonexus-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee320f3214123f1241094ee2e854931c95964cc50bbff77dc7a8ec666f08269f
MD5 4145fd29776ef31bee2ec7a39bb846f1
BLAKE2b-256 34feeb296e0881b4aaa282b36eb30feeaa49a04c2a4fa19abb6c9fc5e45a9f9e

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