-
Why I get the following error?
error: Expression [28]:22:17: 'Python' value has no attribute 'str' |
Beta Was this translation helpful? Give feedback.
Answered by
mfranzon
May 15, 2023
Replies: 1 comment
-
Accordingly to Mojo documentation Python interface has not from PythonInterface import Python
let builtins = Python.import_module("builtins")
let x = builtins.str("Hello Mojo!!")
let slicing = builtins.slice(10)
builtins.print(x[slicing]) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
survuvi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Accordingly to Mojo documentation Python interface has not
str
method, so it is necessary using thebuiltins
python package.Here an example, using the
str
andslice
functions from python to process the string. Also theprint
function from builtins is required to handle str type correctly: