Sum lengths in mixed units using either Soulver CLI or pure Python.
Two implementations:
sum-lengths.py- Pure Python, no dependencies (recommended)soulver-sum-lengths.py- Uses Soulver CLI (requires Soulver installation)
Both convert and sum measurements, outputting:
- Decimal inches (2 decimal places)
- Fractional inches (nearest 1/16″)
- Total in millimeters
- ✅ Accepts fractions:
3 1/2",1/8" - ✅ Accepts feet-inch combos:
5' 3 1/2"→ 5 feet + 3.5 inches - ✅ Accepts mixed units:
mm,cm,inches,feet,meters - ✅ Works interactively or from command-line args
- ✅ Shows the expression for validation
- ✅ Copies result to clipboard automatically (macOS with
pbcopy)
No installation needed - uses Python 3.6+ standard library:
git clone https://github.com/sxdjt/soulver-sum-lengths.git
cd soulver-sum-lengths
chmod +x sum-lengths.pyRequires Soulver CLI:
brew install soulver-cliSingle expression:
python3 sum-lengths.py '2 1/2" + 5.535" + 9mm'Output:
Expression:
sum (2 1/2 inches + 5.535 inches + 9 millimeters)
Result:
8.39"
8 3/8"
213 mm
Separate arguments:
python3 sum-lengths.py 2.5 5.535 9mmWith units:
python3 sum-lengths.py 1ft 6in 25.4mmpython3 sum-lengths.pyEnter lengths (e.g., 2 1/2", 5.535", 9mm). Empty line to finish.
> 2 1/2
> 5.535
> 9mm
>
Expression:
sum (2 1/2 inches + 5.535 inches + 9 millimeters)
Result:
8.39"
8 3/8"
213 mm
chmod +x sum-lengths.py
./sum-lengths.py 2.5 5.535 9mm| Unit Type | Accepted Formats |
|---|---|
| Inches | inch, inches, in, ", ″ |
| Feet | foot, feet, ft, ', ′ |
| Millimeters | millimeter, millimeters, mm |
| Centimeters | centimeter, centimeters, cm |
| Meters | meter, meters, m |
Note: Bare numbers default to inches.
# Mixed fractions
python3 sum-lengths.py '2 1/2" + 3 3/4"'
# Output: 6.25", 6 1/4", 159 mm
# Feet and inches
python3 sum-lengths.py "5' 3\"" 2.5
# Output: 65.50", 65 1/2", 1664 mm
# Metric and imperial
python3 sum-lengths.py 100mm 4in 5cm
# Output: 9.91", 9 7/8", 252 mm
# Decimal inputs
python3 sum-lengths.py 2.5 3.75 1.125
# Output: 7.38", 7 3/8", 187 mmThe script validates inputs and provides helpful error messages:
python3 sum-lengths.py "5 furlongs"
# Error: Unsupported unit: furlongs
python3 sum-lengths.py "1/0"
# Error: Division by zero in fraction- Python 3.6+
- macOS (for clipboard copy via
pbcopy)
No external dependencies required for sum-lengths.py.
python3 test_sum_lengths.pyOr with pytest:
pip install pytest
pytest test_sum_lengths.py -v- PEP 8 compliant
- Type hints for public functions
- Docstrings for all modules and functions
sum-lengths.py: Standalone, no dependencies, better error handlingsoulver-sum-lengths.py: Explores Soulver CLI capabilities, requires Soulver
The pure Python version is recommended for most users.
"No inputs provided"
- Ensure you're passing arguments or using interactive mode
"Cannot parse number"
- Check fraction format: use
1/2not1\2 - Ensure proper spacing:
2 1/2not21/2
Clipboard not working
- Only works on macOS with
pbcopy - Results still display in terminal
MIT License - do whatever you like, attribution appreciated.
Pull requests welcome! Please:
- Add tests for new features
- Follow existing code style
- Update README with examples