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
- How do I copy a file in Python?
- 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
- are there dictionaries in javascript like python?
- How do I update\upgrade pip itself from inside my virtual environment?
- What does the “yield” keyword do?
- Renaming column names in Pandas
- Does Python have a string ‘contains’ substring method?
- Behaviour of increment and decrement operators in Python
- Is there a “not equal” operator in Python?
- IndexError: list index out of range and python
- What is the use of “assert” in Python?
- ‘Conda’ is not recognized as internal or external command
- pip/python: normal site-packages is not writeable
- `from … import` vs `import .` [duplicate]
- How can I safely create a nested directory in Python?
- How to read a text file into a string variable and strip newlines?
- ln (Natural Log) in Python
- How do I select rows from a DataFrame based on column values?
- How to round to 2 decimals with Python?
- How do I concatenate two lists in Python?
- How do I get the row count of a Pandas DataFrame?
- Pinging servers in Python
- TypeError: object of type ‘int’ has no len() error assistance needed
- TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’
- append multiple values for one key in a dictionary [duplicate]
- Import error: No module name urllib2
- Convert a python dict to a string and back
- sys.argv[1] meaning in script
- TypeError: Object of type ‘bytes’ is not JSON serializable
- How to initialize a two-dimensional array in Python?
- How to unpack pkl file?
- What does numpy.gradient do?
- Is there a Python equivalent to the ‘which’ command
- How to run python script in HTML?
- How to clear the interpreter console?
- Countdown timer in Pygame
- Python [Errno 98] Address already in use
- Difference between writerow() and writerows() methods of Python csv module
- Most efficient way to reverse a numpy array
- Python pandas – filter rows after groupby
- Python return list from function
- Python 3: UnboundLocalError: local variable referenced before assignment
- Remove all special characters, punctuation and spaces from string
- How to read a text file into a list or an array with Python
- Map to List error: Series object not callable
- ctypes error: libdc1394 error: Failed to initialize libdc1394
- Python: cannot concatenate ‘str’ and ‘int’ objects error
- installing cPickle with python 3.5
- How to “test” NoneType in python?
- AttributeError:’bytes’ object has no attribute ‘encode’
- python mpl_toolkits installation issue
- What does bitwise_and operator exactly do in openCV?
- RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility
- How to sort 2d array by row in python?
- Using BeautifulSoup to search HTML for string
- Moving average or running mean
- Find which version of package is installed with pip
- What do the python file extensions, .pyc .pyd .pyo stand for?
- Calculate the Cumulative Distribution Function (CDF) in Python
- How to start from second index for for-loop
- Python: How to check if keys exists and retrieve value from Dictionary in descending priority
- Installing opencv on Windows 10 with python 3.6 and anaconda 3.6
- H14 error in heroku – “no web processes running”
- Importing Pandas gives error AttributeError: module ‘pandas’ has no attribute ‘core’ in iPython Notebook
- What does this Django regular expression mean? `?P`
- Strange error about invalid syntax
- ‘virtualenv’ is not recognized as an internal or external command, operable program or batch file
- Python Coin Toss
- Should Python class filenames also be camelCased?
- Is it better to use path() or url() in urls.py for django 2.0?
- Can I remove script tags with BeautifulSoup?
- gunicorn.errors.HaltServer:
django - What is a clean, Pythonic way to have multiple constructors in Python?
- Python Login Script; Usernames and Passwords in a separate file
- Python 2.7 mixing iteration and read methods would lose data
- Conditional indexing with Numpy ndarray
- python numpy machine epsilon
- mport win32ui in python 3.6
- Installing lxml module in python