import { type PythonConvertible } from "https://deno.land/x/python@0.2.5/src/python.ts";
JS types that can be converted to Python Objects.
-
number
becomesint
orfloat
depending on its value. If you need to specifically usefloat
orint
, use thepython.float
orpython.int
classes, like:python.float(42.0)
. Note that they become PyObjects, not JS values but are still easily passable to Python. -
bigint
currently is casted as number and then transformed toint
Python type. -
null
andundefined
becomesNone
in Python. Note that when callingvalueOf
on PyObject, it is alwaysnull
. -
boolean
becomesbool
in Python. -
string
andSymbol
becomesstr
in Python. -
Array
becomeslist
in Python. -
Map
and other objects becomesdict
in Python. Note that when callingvalueOf
on PyObject, it is alwaysMap
because JS object can only have string keys, while Python dict can have any type. -
Set
becomesset
in Python. -
Callback
(custom type) becomes a Python function. First argument passed is an object containing kwargs and rest arguments are positional.
If you pass a PyObject, it is used as-is.
If you pass a PythonProxy, its original PyObject will be used.