M
Modular13mo ago
Igor

`len` of a `PythonObject`

I have a Python list and I want to get the Len of it, but lenPythonObj always seems to return "2"...
2 Replies
Jack Clayton
Jack Clayton13mo ago
Hi you just need to use the one imported from python:
from python import Python

fn main() raises:
let pylen = Python.import_module("builtins").len
let l = Python.evaluate("[5, 8, 10]")
print(pylen(l))
from python import Python

fn main() raises:
let pylen = Python.import_module("builtins").len
let l = Python.evaluate("[5, 8, 10]")
print(pylen(l))
Igor
Igor13mo ago
Let me try that thanks!
Want results from more Discord servers?
Add your server