codon icon indicating copy to clipboard operation
codon copied to clipboard

Throw an ERROR when the Python file includes "input()" command

Open FHYQ-Dong opened this issue 3 years ago • 4 comments

Environment:

ERROR

  • Python file: codon_test.py
a = input()
print(a)
  • Command:
codon run ./codon_test.py
  • Error:
dcodon_test.py:1:5-10: error: name 'input' is not defined
codon_test.py:2:7-8: error: name 'a' is not defined

FHYQ-Dong avatar Dec 13 '22 02:12 FHYQ-Dong

input is not yet implemented by Codon.

inumanag avatar Dec 18 '22 04:12 inumanag

input is not yet implemented by Codon.

Hello, is there a plan to add support for input()?

twelveand0 avatar Mar 07 '23 03:03 twelveand0

Any alternatives to input()?

SwiftWinds avatar Mar 18 '23 08:03 SwiftWinds

@SwiftWinds @FHYQ-Dong @twelveand0 Below is a simple implementation of input().

import sys


def input(string=""):
    print(string, file=sys.stdout)

    for line in sys.stdin:
        return line


a = input("Enter string:")
print(a)

elisbyberi avatar Mar 24 '23 18:03 elisbyberi

This is finally supported with https://github.com/exaloop/codon/commit/5e2d04188ebadb06a8d2d36822f7d0f414d99571

arshajii avatar Aug 05 '24 21:08 arshajii