New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

format-currency

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

format-currency

A no-frill currency formatting library.

  • 0.0.10
  • Source
  • PyPI
  • Socket score

Maintainers
1

Format Numbers as Currencies

A no-frill currency formatting library.


Table of Contents

  • Installation
  • License

Installation

pip install format-currency

Usage

from format_currency import format_currency

# format currency by country code, using the selected country's local monetary number formatting
formatted = format_currency(1234567.89, 'US') # returns $ 1,234,567.89
formatted = format_currency(1234567.89, 'ID') # returns Rp 1.234.567,89

# format currency by currency code
formatted = format_currency(1234567.89, currency_code='USD') # returns $ 1,234,567.89
formatted = format_currency(1234567.89, currency_code='IDR') # returns Rp 1.234.567,89

# smart formatting
formatted = format_currency(value, country_code='CN', smart_number_formatting=True) # returns ¥ 123.46 万

# format currency by country code, respecting global locale settings
import locale
locale.setlocale(locale.LC_ALL, '')

formatted = format_currency(1234567.89, 'US', use_current_locale=True) # returns $ 1,234,567.89
formatted = format_currency(1234567.89, 'ID', use_current_locale=True) # returns Rp 1,234,567.89

Testing

Install dependencies:

python -m pip install --upgrade pip build hatch

Run the test runner:

./test_runner.sh

License

format-currency is distributed under the terms of the MIT license.

References

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc