Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Standard Input from a File
-
I'd like to use Pythonista for coding competitions (practice). On my Windows box, I typically create one file for the solution and multiple files for each test case. Running the solution with a test case looks something like this:
python solution.py < input1
or
cat input1 | python solution.pyAny suggestion for how to achieve this in Pythonista? Ideally I don't want to open a file from within solution.py, but if there is no other solution I'll create some boilerplate code at the beginning of my solutions. I'd like to be able to copy/paste the solution (under the boilerplate if necessary) into the judgeing application. Thus, I would not need to change the following line before submitting for judement:
n,m = map(int, raw_input().split())
for input:
8 3thanks!
-
Look into
StaSH
. I don't have the link offhand, but if you search the forums it should turn up. It has a terminal emulator built in that should handle piping. -
StaSH did the trick!
I followed the instructions here:
https://omz-forums.appspot.com/pythonista/post/5894157600030720After installing I could run solution and test with this command:
cat input1 | python solution.pythanks a lot blmacbeth
-
Glad to help :)