I haven’t reproduced the issue, but perhaps this method would solve it: (writing line by line to stdout
rather than using print
)
import sys with open('a.txt', 'r') as f1: for line in f1: sys.stdout.write(line)
You could catch the broken pipe? This writes the file to stdout
line by line until the pipe is closed.
import sys, errno try: with open('a.txt', 'r') as f1: for line in f1: sys.stdout.write(line) except IOError as e: if e.errno == errno.EPIPE: # Handle error
You also need to make sure that othercommand
is reading from the pipe before it gets too big – https://unix.stackexchange.com/questions/11946/how-big-is-the-pipe-buffer
Related Posts:
- Use Gif Logo For Loading Screen In Kivy
- How can I make a time delay in Python? [duplicate]
- Python – TypeError: ‘int’ object is not iterable
- What is the difference between rw+ and r+
- Python – TypeError: ‘int’ object is not iterable
- Python: ‘ModuleNotFoundError’ when trying to import module from imported package
- Best way to convert string to bytes in Python 3?
- What does the list() function do in Python?
- PermissionError: [Errno 13] Permission denied
- What is setup.py?
- Invalid character in identifier
- Is there a ‘foreach’ function in Python 3?
- Convert bytes to a string
- How to print like printf in Python3?
- Python Error: AttributeError: __enter__ [duplicate]
- TypeError: ‘type’ object is not subscriptable when indexing in to a dictionary
- Invalid character in identifier
- filedialog, tkinter and opening files
- Error in Python script “Expected 2D array, got 1D array instead:”?
- ‘str’ object has no attribute ‘decode’. Python 3 error?
- How to find all the indexes of a recurring item in a list?
- Name ‘xrange’ is not defined in Python 3 [duplicate]
- Error: ” ‘dict’ object has no attribute ‘iteritems’ “
- (Help) TypeError: ‘str’ object cannot be interpreted as an integer
- How do order of operations go on Python?
- Why KeyError: 0
- How to upgrade pip3?
- Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
- TypeError: cannot convert the series to
- builtins.TypeError: must be str, not bytes
- Pinging servers in Python
- Import error: No module name urllib2
- takes 1 positional argument but 2 were given
- ‘End of statement expected’ in pycharm
- Python 3 ImportError: No module named ‘ConfigParser’
- re.search().TypeError: cannot use a string pattern on a bytes-like object
- Change figure size and figure format in matplotlib
- Add Legend to Seaborn point plot
- How can I concatenate str and int objects?
- error: Failed to load the native TensorFlow runtime
- How can I install Python’s pip3 on my Mac?
- ImportError: No module named ‘encodings’
- TypeError(“‘bool’ object is not iterable”,) when trying to return a Boolean
- Get ZeroDivisionError: float division in python
- PermissionError: [WinError 5] Access is denied
- How to delete last item in list?
- Don’t understand this SyntaxError: illegal target for annotation
- Using Queue in python
- TypeError(“‘bool’ object is not iterable”,) when trying to return a Boolean
- Converting int to bytes in Python 3
- How to get the current working directory using python 3?
- min() arg is an empty sequence
- “for line in…” results in UnicodeDecodeError: ‘utf-8’ codec can’t decode byte
- SyntaxError invalid token
- How do I format a string using a dictionary in python-3.x?
- For loop and ‘numpy.float64’ object is not iterable error
- TypeError: cannot unpack non-iterable NoneType object
- python mpl_toolkits installation issue
- Shebang doesn’t work with python3
- Python sockets error TypeError: a bytes-like object is required, not ‘str’ with send function
- Pipenv: Command Not Found
- TypeError: ‘dict_keys’ object does not support indexing
- How to strip all whitespace from string
- Python Binomial Coefficient
- Pip – Fatal error in launcher: Unable to create process using ‘”‘
- pythonw.exe or python.exe?
- How to convert ‘binary string’ to normal string in Python3?
- Properly formatted multiplication table
- python3 TypeError: ‘function’ object is not iterable
- How can I convert a .py to .exe for Python?
- Directing print output to a .txt file
- How to start from second index for for-loop
- Converting a sentence to piglatin in Python
- Python Error – TypeError: input expected at most 1 arguments, got 3 [duplicate]
- A general tree implementation?
- How to compare individual characters in two strings in Python 3
- ModuleNotFoundError: No module named ‘seaborn’ in Python IDE
- Is there a ceiling equivalent of // operator in Python?
- Need to install urllib2 for Python 3.5.1
- ImportError: No module named ‘xlrd’
- Moving Average Pandas
- TypeError: ‘set’ object does not support indexing
- Root mean square of a function in python
- Print empty line?
- Checking to see if a string is an integer or float
- matplotlib: plot multiple columns of pandas data frame on the bar chart
- pip throws TypeError: parse() got an unexpected keyword argument ‘transport_encoding’ when trying to install new packages
- What is the purpose of dollar sign in this Python3 string formatting expression?
- How to know/change current directory in Python shell?
- What is an easy way to implement fprintf in python?
- How to use cmp() in Python 3?
- Generator expression must be parenthesized if not sole argument
- Does python have header files like C/C++?
- How to install NumPy for Python 3.6
- Error: No module named ‘fcntl’
- Python can’t find file
- TypeError: got multiple values for argument
- Accessing dict_keys element by index in Python3
- Python webbrowser.open() to open Chrome browser
- TypeError: ‘zip’ object is not subscriptable