yazzz's blog

By yazzz, history, 3 years ago, In English

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

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it