@@ -3,16 +3,17 @@ module Introduction
33(**
44# Introduction to Fable.Python
55
6- > This post is part of the [ F# Advent Calendar 2025] ( https://sergeytihon.com/2025/11/03/f-advent-calendar-in-english-2025/ ) .
7- Thank you, Sergey Tihon, for organizing this wonderful tradition that brings the F# community together every year!
6+ > This post is part of the [ F# Advent Calendar
7+ 2025] ( https://sergeytihon.com/2025/11/03/f-advent-calendar-in-english-2025/ ) . Thank you, Sergey Tihon, for organizing
8+ this wonderful tradition that brings the F# community together every year!
89
910Welcome to this guide on [ Fable.Python] ( https://github.com/fable-compiler/Fable.Python/ ) -
1011a compiler that transforms F# code into Python.
1112
1213## What is Fable?
1314
14- [ Fable] ( https://fable.io/ ) is a compiler that brings F# to different platforms. While
15- Fable is best known for compiling F# to JavaScript, it also supports other targets
15+ [ Fable] ( https://fable.io/ ) is a compiler that brings F# to different platforms and ecosystems . While
16+ Fable is best known for compiling F# to TypeScript and JavaScript, it also supports other targets
1617including Python, Rust, and Dart.
1718
1819## Why Fable.Python?
@@ -26,9 +27,9 @@ F# is a functional-first language with powerful features like:
2627
2728With Fable.Python, you get all these benefits while targeting the Python ecosystem.
2829
29- Python is the [ most popular programming language] ( https://www.tiobe.com/tiobe-index/ )
30- in the world. And no matter what you think of Python, it will always be the second
31- best language for everything. That ubiquity is exactly why Fable.Python exists.
30+ Python is currently [ the most popular programming language in the world ] ( https://www.tiobe.com/tiobe-index/ ) . And no
31+ matter what you think of Python, it will always be the second best language for everything. That ubiquity is exactly why
32+ Fable.Python exists.
3233
3334## When to Use Fable.Python
3435
@@ -68,12 +69,10 @@ When compiled with Fable, this generates the following Python:
6869(* ** include-python: greet, message ***)
6970
7071(**
71- The ` name: Any | None = None ` signature may look odd at first. This happens because
72- F# infers the type from usage - since we only call ` greet ` with a string, the compiler
73- doesn't know if it might also be called with unit ` () ` (no argument). If it were,
74- Python would call it as ` greet() ` instead of ` greet("Fable.Python") ` . Adding an
75- explicit type annotation ` let greet (name: string) = ... ` would generate a cleaner
76- ` name: str ` parameter.
72+ The ` name: Any | None = None ` signature may look odd at first. This happens because F# infers the type from usage -
73+ since we only call ` greet ` with a string, the compiler doesn't know if it might also be called with unit ` () ` (no
74+ argument). If it were, Python would call it as ` greet() ` instead of ` greet("Fable.Python") ` . Adding an explicit type
75+ annotation ` let greet (name: string) = ... ` would generate a cleaner ` name: str ` parameter.
7776
7877## The Power of Types
7978
@@ -94,16 +93,14 @@ let shapes = [ Circle 5.0; Rectangle(3.0, 4.0) ]
9493let totalArea = shapes |> List.sumBy area
9594
9695(**
97- This compiles to Python while preserving the semantic meaning. The ` Shape ` type
98- becomes a tagged class structure, and the ` match ` expression becomes clean
99- conditional logic. The compiler ensures you handle all cases - if you add a
100- new shape variant, the compiler will warn you about unhandled cases in
101- the ` area ` function.
96+ This compiles to Python while preserving the semantic meaning. The ` Shape ` type becomes a tagged class structure, and
97+ the ` match ` expression becomes clean conditional logic. The compiler ensures you handle all cases, i.e if you add a new
98+ shape variant, the compiler will warn you about unhandled cases in the ` area ` function.
10299
103100## What's Next?
104101
105- In the following chapters, we'll explore setting up your environment,
106- working with Python libraries, and understanding F# compatibility with Fable.
102+ In the following chapters, we'll explore setting up your environment, working with Python libraries, and understanding
103+ F# compatibility with Fable.
107104
108105Let's begin.
109106*)
0 commit comments