This project is part of the 42 School Common Core and focuses on
advanced Python code organization through the import system.
Building on previous modules, this project introduces the concept of
modular architecture and package design, using a themed
alchemy laboratory system.
The goal of this module is to understand and apply:
- Python packages and
__init__.py - module organization and exposure control
- different import styles (
import,from ... import, aliases) - absolute vs relative imports
- circular dependency problems and solutions
- clean project structure and scalability
- error handling through controlled returns
Each part explores a core concept of Python imports, resulting in a
fully structured and reusable Alchemy package system.
All files are organized at the root of the repository, with a main package:
alchemy/
βββ init.py
βββ elements.py
βββ potions.py
βββ transmutation/
β βββ init.py
β βββ basic.py
β βββ advanced.py
βββ grimoire/
β βββ init.py
β βββ spellbook.py
β βββ validator.py
Demonstration scripts (mains):
- `ft_sacred_scroll.py`
- `ft_import_transmutation.py`
- `ft_pathway_debate.py`
- `ft_circular_curse.py`
Introduces Python packages and __init__.py.
- Creates the
alchemypackage - Controls what functions are exposed
- Demonstrates package vs module access
Concepts: package initialization, interface control, encapsulation
Focuses on different import styles.
- Uses
import,from ... import, aliases - Builds potion functions using elements
- Demonstrates how imports affect readability and usage
Concepts: import styles, code reuse, modular calls
Explores absolute vs relative imports.
- Implements nested package (
transmutation) - Uses both import styles
- Shows how both reach the same functionality
Concepts: absolute imports, relative imports, package navigation
Introduces circular dependencies and solutions.
- Simulates dependency conflicts between modules
- Implements validation system
- Uses techniques to avoid circular imports
Concepts: circular dependencies, late imports, dependency design
__init__.pydefines what a package exposes- Imports are not just syntax β they define architecture
- Relative imports improve maintainability inside packages
- Absolute imports improve clarity and readability
- Circular dependencies are a design problem, not just a bug
- Clean structure > complex logic
- Written for Python 3.10+
- Fully compliant with flake8
- Follows 42 naming conventions
- All functions return strings (as required)
- Focus is on import behavior, not algorithm complexity
- Outputs match the subject examples exactly