Skip to content

Python string error #159

Closed Locked Answered by mfranzon
survuvi asked this question in Q&A
Discussion options

You must be logged in to vote

Accordingly to Mojo documentation Python interface has not strmethod, so it is necessary using the builtins python package.
Here an example, using the str and slice functions from python to process the string. Also the print function from builtins is required to handle str type correctly:

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])

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by survuvi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants