reuters-style
raw JSON → 0.0.5 verified Sat May 09 auth: no python
Format dates, numbers and text to conform with the Reuters Style Guide. Current version is 0.0.5, released in 2024. Release cadence is irregular.
pip install reuters-style Common errors
error ModuleNotFoundError: No module named 'reuters_style' ↓
cause Package not installed or imported incorrectly.
fix
Install with
pip install reuters-style and import as from reuters_style import ... error TypeError: ReutersStyle() got an unexpected keyword argument 'date_format' ↓
cause Constructor does not accept arbitrary keyword arguments.
fix
Check documentation for valid parameters; currently only 'locale' is supported.
Warnings
gotcha The package import uses underscores (reuters_style) not hyphens. ↓
fix Use `import reuters_style` or `from reuters_style import ...`
deprecated Some functionality may be removed in future versions without prior notice. The package is in early development (pre-1.0). ↓
fix Pin to a specific version and review changelogs before upgrading.
gotcha The ReutersStyle class caches some data; creating a new instance per request may be inefficient. ↓
fix Reuse the same instance when possible.
Imports
- ReutersStyle
from reuters_style import ReutersStyle - Slug
from reuters_style import Slug - RIC
from reuters_style import RIC
Quickstart
from reuters_style import ReutersStyle
# Format a date
style = ReutersStyle()
print(style.format_date('2024-01-01')) # Output: 'Jan 1'
# Format a number
print(style.format_number(1234567)) # Output: '1,234,567'
# Format text
print(style.format_text('Mr. John Smith')) # Output: 'John Smith'