quick Python question regarding running testcases locally (need some help)

Revision en6, by yazzz, 2021-08-11 18:47:56

Hey, (sorry for my English)

quick summary of my question does anyone know the Python equivalent of this command from c++ "g++ -std=c++11 -O2 -Wall cf.cpp -o test". Basically, I just want to produce a binary file named test for my python code, so I can just run this command ./test < in (where the file in will have the sample test cases).

This works very effortlessly in c++ but I have not found any solution so far using Python.

Say I have this Python Code:

  • t=int(input())
  • for _ in range(t):
  • n = int(input())
  • a = list(map(int, input().split()))
  • print(*a)

I want to just print the information from in, which should help me test the code a lot faster.

where for example the file in would contain:

  • 2
  • 3
  • 1 2 3
  • 4
  • 1 2 3 4

Any help would be much appreciated! thanks in advance.

UPD: After taking some time to understand what I was actually looking for I was able to find a solution. There seem to be two ways to do it:

  1. < in python test.py
  2. cat in | python test.py
Tags python, input, #testcase

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English yazzz 2021-08-11 18:47:56 202
en5 English yazzz 2021-08-11 15:40:39 0 (published)
en4 English yazzz 2021-08-11 15:40:19 15
en3 English yazzz 2021-08-11 15:39:47 10
en2 English yazzz 2021-08-11 15:37:23 20 (saved to drafts)
en1 English yazzz 2021-08-11 15:36:21 891 Initial revision (published)