11# Introduction to Fable.Python
22
3- * Generated on 2026-03-08 17:54 UTC using Fable v5.0.0-rc.2 *
3+ * Generated on 2026-05-14 16:03 UTC using Fable v5.0.0*
44
55> This post is part of the [ F# Advent Calendar
66 2025] ( https://sergeytihon.com/2025/11/03/f-advent-calendar-in-english-2025/ ) . Thank you, Sergey Tihon, for organizing
@@ -399,10 +399,10 @@ dotnet new console -lang F#
399399
400400# Set up local tools and install Fable 5
401401dotnet new tool-manifest
402- dotnet tool install fable --version 5.0.0-rc.2
402+ dotnet tool install fable --version 5.0.0
403403
404404# Add Fable.Core package
405- dotnet add package Fable.Core --version 5.0.0-rc.1
405+ dotnet add package Fable.Core --version 5.0.0
406406```
407407
408408### Install Python Dependencies
@@ -411,17 +411,16 @@ Fable-generated Python code requires the `fable-library` runtime:
411411
412412``` bash
413413# Using uv (recommended)
414- uv add " fable-library==5.0.0rc2 "
414+ uv add " fable-library==5.0.0 "
415415
416416# Or with pip
417- pip install " fable-library==5.0.0rc2 "
417+ pip install " fable-library==5.0.0 "
418418```
419419
420420---
421421
422422** Note:** Version pinning matters. The fable-library version must match your Fable
423- compiler version. Note that PyPI uses ` 5.0.0rc2 ` format instead of ` 5.0.0-rc.2 ` for
424- prerelease release candidate versions.
423+ compiler version.
425424
426425---
427426
@@ -529,15 +528,22 @@ For basic JSON operations, use Python's built-in `json` module:
529528``` fsharp
530529open Fable.Python.Json
531530
532- // Serialize F# data to JSON string
531+ // Serialize F# data to a JSON string
533532let data = {|
534533 name = "Alice"
535534 age = 30
536535|}
536+
537+ let encoded = json.dumps data
538+ // '{"name": "Alice", "age": 30}'
539+
540+ // Parse a JSON string back to a Python dict
541+ let decoded = json.loads """{"city": "Oslo", "temp": -5}"""
537542```
538543
539544Anonymous records (` {| ... |} ` ) are perfect for JSON - they compile to
540- Python dictionaries. See the Compatibility chapter for details on how F#
545+ Python dictionaries, so ` json.dumps ` and ` json.loads ` work directly without
546+ any conversion layer. See the Compatibility chapter for details on how F#
541547types map to Python types.
542548
543549### Calling Python Functions
@@ -2325,8 +2331,8 @@ project setup:
23252331 <ItemGroup >
23262332 <PackageReference Include =" Expecto" Version =" 10.2.1" />
23272333 <PackageReference Include =" Fable.Pyxpecto" Version =" 2.0.0" />
2328- <PackageReference Include =" Fable.Core" Version =" 5.0.0-rc.1 " />
2329- <PackageReference Include =" Fable.Python" Version =" 5.0.0-rc.2 " />
2334+ <PackageReference Include =" Fable.Core" Version =" 5.0.0" />
2335+ <PackageReference Include =" Fable.Python" Version =" 5.1.0 " />
23302336 </ItemGroup >
23312337
23322338 <ItemGroup >
@@ -2458,17 +2464,16 @@ pip install fable-library
24582464uv add fable-library
24592465```
24602466
2461- For projects, pin your dependencies in ` pyproject.toml ` . For stable releases use
2462- a minimum version constraint:
2467+ For projects, pin your dependencies in ` pyproject.toml ` :
24632468
24642469``` toml
24652470dependencies = [" fable-library>=5.0.0" ]
24662471```
24672472
2468- For pre-release versions, pin the exact version to avoid surprises :
2473+ To pin an exact version, use :
24692474
24702475``` toml
2471- dependencies = [" fable-library==5.0.0rc2 " ]
2476+ dependencies = [" fable-library==5.0.0 " ]
24722477```
24732478
24742479This makes dependency management much simpler and follows Python conventions.
@@ -2491,13 +2496,13 @@ To use Fable v5, install the CLI:
24912496
24922497``` bash
24932498# Install Fable 5 CLI
2494- dotnet tool install fable --version 5.0.0-rc.2
2499+ dotnet tool install fable --version 5.0.0
24952500
24962501# Add Fable.Core to your project
2497- dotnet add package Fable.Core --version 5.0.0-rc.1
2502+ dotnet add package Fable.Core --version 5.0.0
24982503
24992504# Install the Python runtime
2500- uv add fable-library==5.0.0rc2
2505+ uv add fable-library==5.0.0
25012506```
25022507
25032508Then compile your F# to Python:
@@ -3708,7 +3713,7 @@ For example, the extractSymbol function in F# generates this Python:
37083713def extract_symbol (symbol : str , lines : Array[str ]) -> str | None :
37093714 """ Extracts a single symbol definition from Python source lines."""
37103715
3711- def mapping (def_index : int32, symbol : Any = symbol, lines : Any = lines) -> str :
3716+ def mapping (def_index : int32, lines : Any = lines) -> str :
37123717 start_index: int32 = find_decorator_start(lines, def_index)
37133718 if is_multiline_definition(lines[def_index]):
37143719 return extract_multiline_body(start_index, def_index, lines)
0 commit comments