Python-iOS icon indicating copy to clipboard operation
Python-iOS copied to clipboard

how to run python input function?

Open Sunny-guangge opened this issue 1 year ago • 4 comments

Sunny-guangge avatar Feb 29 '24 07:02 Sunny-guangge

def main(): # print('00') n1 = 10 n2 = 20 print(n1, '+', n2, '= ?') a = input('send something') a = int(a) b = n1 + n2 if b == a: print('good!') else: print('sorry', b)

in ios project how to implement the input function

Sunny-guangge avatar Feb 29 '24 10:02 Sunny-guangge

You can build UI using SwiftUI or UIKit and pass user input to Python code.

kewlbear avatar Mar 04 '24 23:03 kewlbear

You can build UI using SwiftUI or UIKit and pass user input to Python code.

but How to maintain the python running environment? When I receive a prompt to 'send something' and then enter a number, continue executing the subsequent python code?

Sunny-guangge avatar Mar 11 '24 03:03 Sunny-guangge

I see. So you want to keep using standard input/output. I guess it's possible but not easy. You can make a Pipe object and replace file descriptors of standard input/output with pipe's. Then either handle events or utilize async/await.

kewlbear avatar Mar 11 '24 08:03 kewlbear