[Feature Request] Implement `input` builtin
Bug Description
Just received playground access and excited to explore more of Mojo. Thank you to the maintainers of this new project!
So far, I am unable to use Python builtin input(...) to collect user provided inputs. This can be useful in prompts and dynamically reading inputs when necessary. Was not able to get it to work using Mojo or Python.
Steps to Reproduce
Mojo
val = input("Enter your value: ")
error: Expression [3]:16:11: use of unknown declaration 'input'
val = input("Enter your value: ")
^~~~~
Python
val = input("Enter your value: ")
It just hangs the kernel after execution without a way of supplying the input. Normally, a textbox field opens allowing you to submit on Enter.
Context
11:blkio:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podebe6bc3d_c66b_4907_b5b5_d43ec91b4335.slice/cri-containerd-5bf88e19fd1f66e635a1e885aef21257e72cdcd62638d298839d39c4dc0dd50b.scope
10:freezer:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podebe6bc3d_c66b_4907_b5b5_d43ec91b4335.slice/cri-containerd-5bf88e19fd1f66e635a1e885aef21257e72cdcd62638d298839d39c4dc0dd50b.scope
9:devices:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podebe6bc3d_c66b_4907_b5b5_d43ec91b4335.slice/cri-containerd-5bf88e19fd1f66e635a1e885aef21257e72cdcd62638d298839d39c4dc0dd50b.scope
8:hugetlb:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podebe6bc3d_c66b_4907_b5b5_d43ec91b4335.slice/cri-containerd-5bf88e19fd1f66e635a1e885aef21257e72cdcd62638d298839d39c4dc0dd50b.scope
7:cpu,cpuacct:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podebe6bc3d_c66b_4907_b5b5_d43ec91b4335.slice/cri-containerd-5bf88e19fd1f66e635a1e885aef21257e72cdcd62638d298839d39c4dc0dd50b.scope
6:cpuset:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podebe6bc3d_c66b_4907_b5b5_d43ec91b4335.slice/cri-containerd-5bf88e19fd1f66e635a1e885aef21257e72cdcd62638d298839d39c4dc0dd50b.scope
5:pids:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podebe6bc3d_c66b_4907_b5b5_d43ec91b4335.slice/cri-containerd-5bf88e19fd1f66e635a1e885aef21257e72cdcd62638d298839d39c4dc0dd50b.scope
4:memory:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podebe6bc3d_c66b_4907_b5b5_d43ec91b4335.slice/cri-containerd-5bf88e19fd1f66e635a1e885aef21257e72cdcd62638d298839d39c4dc0dd50b.scope
3:perf_event:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podebe6bc3d_c66b_4907_b5b5_d43ec91b4335.slice/cri-containerd-5bf88e19fd1f66e635a1e885aef21257e72cdcd62638d298839d39c4dc0dd50b.scope
2:net_cls,net_prio:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podebe6bc3d_c66b_4907_b5b5_d43ec91b4335.slice/cri-containerd-5bf88e19fd1f66e635a1e885aef21257e72cdcd62638d298839d39c4dc0dd50b.scope
1:name=systemd:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podebe6bc3d_c66b_4907_b5b5_d43ec91b4335.slice/cri-containerd-5bf88e19fd1f66e635a1e885aef21257e72cdcd62638d298839d39c4dc0dd50b.scope
0::/
Faced the same issue too:
Please fix this bug ASAP.
Please fix this bug ASAP.
sorry for disturbing the thread, but this is priceless. 🤦🏻♂️
In the beta you can use python imports to use input in *.mojo files as follows:
from python import Python as py
def main():
input = py.import_module("builtins").input
print(input())
Note that this still doesn't work in notebooks, neither locally nor in the playground.