Skip to main content

python_solar-system

An object-oriented model of a (fantasy) solar system - a Python re-imagining of the original java_solar-system project, preserving its domain principles while expressing them idiomatically in Python.

Domain principles (carried over from the Java version)

Java Python Principle
Planet.java solar_system/planet.py A planet has a name, mass (Earth masses) and distance (AU); it derives its orbital period from Kepler's third law T = √(a³).
getters/setters over fields validated @property accessors Encapsulation - values are validated on assignment and reported rounded to 3 decimals.
SolarSystem.java solar_system/solar_system.py A named, ordered collection of planets with an overloaded add_planet.
overloaded addPlanet type-dispatching add_planet Accepts either a Planet or (name, mass, distance).
FantasySolarSystem.java solar_system/cli.py Interactive driver: prompts for a system name, reads planet names until done, assigns random mass/distance in [0, 50), prints each planet, then a formatted table.

Layout

python_solar-system/
├── solar_system/
│   ├── __init__.py        # package exports (Planet, SolarSystem)
│   ├── planet.py          # Planet domain object
│   ├── solar_system.py    # SolarSystem aggregate (sequence protocol)
│   ├── cli.py             # interactive driver + table formatting
│   └── __main__.py        # `python -m solar_system`
├── tests/                 # pytest suite
├── pyproject.toml
└── README.md

Running

From inside python_solar-system/:

# Run the interactive fantasy builder
python -m solar_system

# Or, after `pip install -e .`
fantasy-solar-system

Example session:

Enter the name of the solar system:Andromeda
Now enter planet names - type 'done' to finish
Enter name: Krypton
Planet Krypton has a mass of 12.34 Earths, is 5.6AU from its star, and orbits in 13.25 years
Enter name: done

Name       Mass                 Distance             Period (years)
Krypton    12.34                5.6                  13.25

Programmatic use

from solar_system import Planet, SolarSystem

system = SolarSystem("Sol")
system.add_planet("Earth", mass=1.0, distance=1.0)
system.add_planet(Planet("Mars", 0.107, 1.524))

for planet in system:               # SolarSystem is iterable
    print(planet.name, planet.orbital_period)

print(system)                        # full multi-line summary

Tests

pip install -e ".[test]"
pytest

Origin

This codebase began as an artifact of a conversation about Self-Realization as the key to avoiding failure — recorded with a YouTube creator whose work reaches roughly 14k monthly views. Porting the 2017 Java original to a clean, test-backed Python design was the practical companion to that conversation: a small, deliberate act of building something true to its own first principles.

Credit

Domain and behaviour derived from the original Java project, © 2017 Richard A. Famoroti.

Metadata

Release files for famoroti-solar-system 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for famoroti-solar-system 1.0.0
File Size Uploaded
famoroti_solar_system-1.0.0.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for famoroti-solar-system 1.0.0
File Interpreter ABI Platform
famoroti_solar_system-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / famoroti_solar_system-1.0.0.tar.gz

Download URL famoroti_solar_system-1.0.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
31b75d0e5c1aadf95fa57a8113441cc130e0ab89a87b8e691ae2a0dd669d908d
BLAKE2b-256 checksum
How to use checksums
fdaa2342366caac8d89060a68e355458730f32b08d95735f882cd23509ca06e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release files / famoroti_solar_system-1.0.0-py3-none-any.whl

Download URL famoroti_solar_system-1.0.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
450ba348dc8cd532332c603b2f983e8cacb5b85564491aa2b5eea55b2e7e01ab
BLAKE2b-256 checksum
How to use checksums
dc51a925f3c441f8d7901235041568f040ddc3effc36e827d6e8ea17c9990956
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page