RomanPy


NameRomanPy JSON
Version 1.1.1 PyPI version JSON
download
home_pageNone
SummaryEffortlessly convert decimal numbers to Roman numerals in Python.
upload_time2025-08-15 21:50:58
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords unicode decimal numbers roman numbers conversion numeral system
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RomanPy

[![pipeline status](https://gitlab.com/parcifal/roman-py/badges/master/pipeline.svg)](https://gitlab.com/parcifal/roman-py/-/pipelines)
[![coverage report](https://gitlab.com/parcifal/roman-py/badges/master/coverage.svg)](https://gitlab.com/parcifal/roman-py/-/commits/master)
[![PyPI version](https://img.shields.io/pypi/v/RomanPy)][pypi]

RomanPy is a simple Python library for converting between decimal numbers and 
Roman numerals. It supports ASCII and Unicode output, upper- and lowercase
forms, and even allows arithmetic operations with Roman numerals.

> Licensed under the [AGPLv3.0](LICENSE).

## Installation

```bash
pip install RomanPy
```

## Usage

### Basic Conversion

```python
from roman import roman

print(roman(207))  # CCVII
```

### Encoding and Case Variants

RomanPy supports ASCII and Unicode numerals, both in upper- and lowercase,  
using methods similar to Python’s built-in `str` API:

```python
numeral = roman(1776)

# ascii (default), uppercase (default)
print(numeral.encode("ascii").upper())  # MDCCLXXVI

# ascii, lowercase
print(numeral.encode("ascii").lower())  # mdcclxxvi

# unicode, uppercase
print(numeral.encode("unicode").upper())  # ⅯⅮⅭⅭⅬⅩⅩⅥ

# unicode, lowercase
print(numeral.encode("unicode").lower())  # ⅿⅾⅽⅽⅼⅹⅹⅵ
```

### Arithmetic with Roman Numerals

Roman numerals can be added, subtracted, multiplied, or divided with  
other Roman numerals or integers:

```python
print(roman(100) + roman(60))   # CLX
print(roman(45) - roman(7))     # XXXIX
print(roman(533) * roman(2))    # MLXVI
print(roman(2460) / roman(10))  # CCXLVI

# mixing with integers
print(100 + roman(60))          # CLX
print(roman(45) - 7)            # XXXIX
print(roman(533) * 2)           # MLXVI
print(2460 / roman(10))         # CCXLVI
```

### Comparisons

Equality works between Roman numerals, integers, and strings:

```python
print(roman(335) == roman(335))     # True
print(roman(24) == 24)              # True
print(roman(1954) == "MCMLIV")      # True
```

## Command-Line Tool

Installing `RomanPy` also provides a `roman` CLI tool for quick conversions.

```bash
roman 42 # = XLII
```

### CLI Usage
```help
usage: roman [-h] [-a | -A | -u | -U] [-v] value

Convert a decimal number to roman numeral.

positional arguments:
  value          a decimal number to convert to a Roman numeral

optional arguments:
  -h, --help     show this help message and exit
  -a, --ascii    output encoding of Roman numerals in lowercase ASCII
  -A, --ASCII    output encoding of Roman numerals in uppercase ASCII (default)
  -u, --unicode  output encoding of Roman numerals in lowercase unicode
  -U, --UNICODE  output encoding of Roman numerals in uppercase unicode
  -v, --version  show program's version number and exit
```

## Contributing

Found a bug? Have a suggestion? Open an issue or submit a merge request at 
[the GitLab repository](https://gitlab.com/parcifal/roman-py). All 
contributions are welcome.

[pypi]: https://pypi.org/project/RomanPy/

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "RomanPy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "unicode, decimal numbers, roman numbers, conversion, numeral system",
    "author": null,
    "author_email": "\"M.P. van de Weerd\" <michael@parcifal.dev>",
    "download_url": "https://files.pythonhosted.org/packages/43/25/bd922449394eb87c19414859b5d3b6e4a54d0aa94d12e8dab2cc2852fa4d/romanpy-1.1.1.tar.gz",
    "platform": null,
    "description": "# RomanPy\n\n[![pipeline status](https://gitlab.com/parcifal/roman-py/badges/master/pipeline.svg)](https://gitlab.com/parcifal/roman-py/-/pipelines)\n[![coverage report](https://gitlab.com/parcifal/roman-py/badges/master/coverage.svg)](https://gitlab.com/parcifal/roman-py/-/commits/master)\n[![PyPI version](https://img.shields.io/pypi/v/RomanPy)][pypi]\n\nRomanPy is a simple Python library for converting between decimal numbers and \nRoman numerals. It supports ASCII and Unicode output, upper- and lowercase\nforms, and even allows arithmetic operations with Roman numerals.\n\n> Licensed under the [AGPLv3.0](LICENSE).\n\n## Installation\n\n```bash\npip install RomanPy\n```\n\n## Usage\n\n### Basic Conversion\n\n```python\nfrom roman import roman\n\nprint(roman(207))  # CCVII\n```\n\n### Encoding and Case Variants\n\nRomanPy supports ASCII and Unicode numerals, both in upper- and lowercase,  \nusing methods similar to Python\u2019s built-in `str` API:\n\n```python\nnumeral = roman(1776)\n\n# ascii (default), uppercase (default)\nprint(numeral.encode(\"ascii\").upper())  # MDCCLXXVI\n\n# ascii, lowercase\nprint(numeral.encode(\"ascii\").lower())  # mdcclxxvi\n\n# unicode, uppercase\nprint(numeral.encode(\"unicode\").upper())  # \u216f\u216e\u216d\u216d\u216c\u2169\u2169\u2165\n\n# unicode, lowercase\nprint(numeral.encode(\"unicode\").lower())  # \u217f\u217e\u217d\u217d\u217c\u2179\u2179\u2175\n```\n\n### Arithmetic with Roman Numerals\n\nRoman numerals can be added, subtracted, multiplied, or divided with  \nother Roman numerals or integers:\n\n```python\nprint(roman(100) + roman(60))   # CLX\nprint(roman(45) - roman(7))     # XXXIX\nprint(roman(533) * roman(2))    # MLXVI\nprint(roman(2460) / roman(10))  # CCXLVI\n\n# mixing with integers\nprint(100 + roman(60))          # CLX\nprint(roman(45) - 7)            # XXXIX\nprint(roman(533) * 2)           # MLXVI\nprint(2460 / roman(10))         # CCXLVI\n```\n\n### Comparisons\n\nEquality works between Roman numerals, integers, and strings:\n\n```python\nprint(roman(335) == roman(335))     # True\nprint(roman(24) == 24)              # True\nprint(roman(1954) == \"MCMLIV\")      # True\n```\n\n## Command-Line Tool\n\nInstalling `RomanPy` also provides a `roman` CLI tool for quick conversions.\n\n```bash\nroman 42 # = XLII\n```\n\n### CLI Usage\n```help\nusage: roman [-h] [-a | -A | -u | -U] [-v] value\n\nConvert a decimal number to roman numeral.\n\npositional arguments:\n  value          a decimal number to convert to a Roman numeral\n\noptional arguments:\n  -h, --help     show this help message and exit\n  -a, --ascii    output encoding of Roman numerals in lowercase ASCII\n  -A, --ASCII    output encoding of Roman numerals in uppercase ASCII (default)\n  -u, --unicode  output encoding of Roman numerals in lowercase unicode\n  -U, --UNICODE  output encoding of Roman numerals in uppercase unicode\n  -v, --version  show program's version number and exit\n```\n\n## Contributing\n\nFound a bug? Have a suggestion? Open an issue or submit a merge request at \n[the GitLab repository](https://gitlab.com/parcifal/roman-py). All \ncontributions are welcome.\n\n[pypi]: https://pypi.org/project/RomanPy/\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Effortlessly convert decimal numbers to Roman numerals in Python.",
    "version": "1.1.1",
    "project_urls": {
        "Bug Tracker": "https://gitlab.com/parcifal/roman-py/-/issues",
        "Homepage": "https://gitlab.com/parcifal/roman-py"
    },
    "split_keywords": [
        "unicode",
        " decimal numbers",
        " roman numbers",
        " conversion",
        " numeral system"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "168bc5ae1dc627778a53646eaa8b1568130de4c8a1d9a1ea21556117e7707b61",
                "md5": "39dd20a7ea3706a3470cec1d72b8bd5b",
                "sha256": "bbca4eece037319d0e44a4a5c9258994752c9bf43c52f6357be75d5bdf2a5bd7"
            },
            "downloads": -1,
            "filename": "romanpy-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "39dd20a7ea3706a3470cec1d72b8bd5b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14154,
            "upload_time": "2025-08-15T21:50:57",
            "upload_time_iso_8601": "2025-08-15T21:50:57.075621Z",
            "url": "https://files.pythonhosted.org/packages/16/8b/c5ae1dc627778a53646eaa8b1568130de4c8a1d9a1ea21556117e7707b61/romanpy-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4325bd922449394eb87c19414859b5d3b6e4a54d0aa94d12e8dab2cc2852fa4d",
                "md5": "e25529b429eec0624e0f249dfbce7073",
                "sha256": "77418e33e47d8655635be2fa913783eadbe4726edba943532cb0d27a7d6e501a"
            },
            "downloads": -1,
            "filename": "romanpy-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "e25529b429eec0624e0f249dfbce7073",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15527,
            "upload_time": "2025-08-15T21:50:58",
            "upload_time_iso_8601": "2025-08-15T21:50:58.215106Z",
            "url": "https://files.pythonhosted.org/packages/43/25/bd922449394eb87c19414859b5d3b6e4a54d0aa94d12e8dab2cc2852fa4d/romanpy-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-15 21:50:58",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "parcifal",
    "gitlab_project": "roman-py",
    "lcname": "romanpy"
}
        
Elapsed time: 2.24820s