

GitHub - fable-compiler/Fable.Python: Python bindings for Fable
source link: https://github.com/fable-compiler/Fable.Python
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Fable Python
Fable is a compiler that translates F# source files to JavaScript and Python.
This Fable Python repository contains the Python bindings for Fable. This library will eventually contain Python (stdlib) bindings for Fable based on Python typeshed. It will also contain type binding for many other libraries as well such as Flask, MicroBit and many more. Some bindings have already been added:
- Python Standard Libray
- Jupyter
- Flask
- MicroBit
- CogniteSdk
Installation
Prerequisite for compiling F# to Python using Fable:
> dotnet tool install --global fable-py --version 4.0.0-alpha-004 > dotnet add package Fable.Core.Experimental --version 4.0.0-alpha-005
To use the Fable.Python
library in your Fable project:
> dotnet package add Fable.Python
Usage
open Fable.Python.Json let object = {| A=10; B=20 |} let result = json.dumps object
To compile an F# Fable project to Python run e.g:
> dotnet fable-py MyProject.fsproj
For more examples see the examples folder. It contains example code for using Fable Python with:
- Flask. References Feliz.ViewEngine as a nuget package.
- MicroBit
- Timeflies, Cool demo using Tkinter and references FSharp.Control.AsyncRx as a nuget package.
Contributing
If the type binding you are looking for is currently missing (it probably is), then add it to the relavant files (or add new ones). Open a PR to get them included. There's not much Python specific documentation yet, but the process of adding type bindings for Python is similar to JS:
Differences from JS
Note that import all is different from JS. E.g:
[<ImportAll("flask")>] let flask: IExports = nativeOnly
This will generate import flask
and not a wildcard import from flask import *
. The latter version is discoraged anyways.
Auto-generation
Parts of this library could benefit from code-generation based on the type annotations in Python typeshed similar to ts2fable. Even so we should keep this library manually updated based on PRs to ensure the quality of the code.
Current plan:
- Add bindings for Python
ast
module (in progress) - Use
ast
module to parse Python typeshed annotations - Generate F# bindings
Recommend
-
8
Fable.Store This repository was originally born as bindings to write Svelte apps with Fable, but has evolved into providing stores à-la-Svelte that can also be used with other UI rendering mechanisms like React, and also in non-Fable...
-
9
Copy link Contributor thinkbeforecoding
-
8
Fable.Storybook Fable bindings for the @storybook/react NPM package. Nuget Packages Stable Prerelease Getting Started Configure your Fab...
-
15
Copy link Contributor dbrattli commented
-
14
Fable.I18Next Fable bindings and helpers for i18next. The bindings work with Fable and on .NET Core for ServerSide-Rendering. Created by @atheck.
-
9
Fable.Haunted Haunted bindings for Fable Too stringy? check out
-
14
Fable Python |> F# ♥️ Python This website stores cookies on your computer. These cookies are used to collect information about how you interact with our website and allow us to remember you. We use this information...
-
10
F# and Fable (Python) support for Jupyter Fable Python is an F# kernel for Jupyter based on Fable and IPythonKernel. Fable is a transpiler that conver...
-
5
Fable Compiler on Twitter: "Fable 3.6 is out!🚀 👉 Support #fsharp 6 syntax 👉 Support DateOnly/TimeOnly thanks to @keramss 👉 Speed up watch mode for big projects Have a nice weekend!"Don’t miss what’s happeningPeople on Twitter are...
-
10
davedawkins/Fable.Appwrite: Appwrite bindings for Fable (F#) Skip to content...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK