I found this to be the only one short, flexible, portable and readable:
from __future__ import print_function import sys def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs)
The function eprint
can be used in the same way as the standard print
function:
>>> print("Test") Test >>> eprint("Test") Test >>> eprint("foo", "bar", "baz", sep="---") foo---bar---baz
Related Posts:
- How to print to stderr in Python?
- print variable and a string in python
- multiple prints on the same line in Python
- print variable and a string in python
- Print multiple arguments in Python
- Why is parenthesis in print voluntary in Python 2.7?
- Python 3 print without parenthesis
- What is the purpose of the return statement?
- How to best print output to command window during a loop in Matlab?
- Python: TypeError: cannot concatenate ‘str’ and ‘int’ objects
- How can I flush the output of the print function?
- Print in new line, java
- How to print instances of a class using print()?
- How can I print variable and string on same line in Python?
- Printing variables in Python 3.4
- Easy pretty printing of floats?
- Scheme console printing
- In python, how can I print lines that do NOT contain a certain string, rather than print lines which DO contain a certain string:
- Using print() (the function version) in Python2.x
- TypeError: ‘builtin_function_or_method’ object is not subscriptable
- numpy max vs amax vs maximum
- What does “while True” mean in Python?
- TypeError: ‘str’ object is not callable (Python)
- Converting string into datetime
- ValueError: invalid literal for int() with base 10: ”
- How do I list all files of a directory?
- Print string to text file
- How can I implement a tree in Python?
- How can I parse a YAML file in Python
- STDERR? What is it? What are its common uses?
- TypeError: ‘float’ object not iterable
- write() versus writelines() and concatenated strings
- Why is it string.join(list) instead of list.join(string)?
- How to print the array?
- Importing class from another file [duplicate]
- Pandas group-by and sum
- Is it possible to compile a program written in Python?
- Python List vs. Array – when to use?
- How to terminate a script?
- numpy array concatenate: “ValueError: all the input arrays must have same number of dimensions”
- Print ArrayList
- csv.Error: iterator should return strings, not bytes
- What does “SyntaxError: Missing parentheses in call to ‘print'” mean in Python?
- No acceptable C compiler found in $PATH when installing python
- Python – Module Not Found
- anaconda/conda – install a specific package version
- What is the purpose of “pip install –user …”?
- How to upgrade all Python packages with pip
- SyntaxError: cannot assign to operator
- How to have an array of arrays in Python
- LSTM Keras input shape confusion
- Detect whether a Python string is a number or a letter
- How to increase plt.title font size?
- ‘list’ object has no attribute ‘shape’
- How do I find the duplicates in a list and create another list with them?
- What is the meaning of single and double underscore before an object name?
- What is the difference between np.mean and tf.reduce_mean?
- How do I combine two dataframes?
- How can I get list of values from dict?
- How do I append one string to another in Python?
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- How to sort a list of objects based on an attribute of the objects?
- ValueError: x and y must be the same size
- TypeError: ‘int’ object does not support item assignment
- Loading a file with more than one line of JSON into Pandas
- SystemError: new style getargs format but argument is not a tuple?
- How to convert bytearray to string in python
- Subtracting two lists in Python
- Is there any way to kill a Thread?
- BeautifulSoup getting href
- Equivalent of shell ‘cd’ command to change the working directory?
- What is PEP8’s E128: continuation line under-indented for visual indent?
- ValueError: zero length field name in format in Python2.6.6
- Python NameError, variable ‘not defined’
- Cannot import cv2 in python in OSX
- numpy-equivalent of list.pop?
- How to get row number in dataframe in Pandas?
- Difference between Python’s Generators and Iterators
- “Unorderable types: int() < str()"
- python : an integer is required (got type str)
- Django Rest Framework — no module named rest_framework
- Unsupported operation :not writeable python
- RuntimeError: Invalid DISPLAY variable
- Disable / Enable Button in TKinter
- Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support
- How do I find the time difference between two datetime objects in python?
- How to strip a specific word from a string?
- Printing subscript in python
- Installing scipy for python 2.7
- Installing MySQL-python causes command ‘clang’ failed with exit status 1 on Mac OS 10.13.15
- Get difference between two lists
- how to build .exe for python 3.5+, 3.6 if possible?
- How to query as GROUP BY in django?
- Python regex match space only
- OpenCV houghLinesP parameters
- How to download a file via FTP with Python ftplib
- How do I restart a program based on user input?
- Python Pandas : pivot table with aggfunc = count unique distinct
- Flask Value error view function did not return a response [duplicate]
- How do you fetch the authors email or IP from /comments? (REST API)