You can use the print
statement to do this without importing sys
.
def install_xxx(): print "Installing XXX... ", install_xxx() print "[DONE]"
The comma on the end of the print
line prevents print
from issuing a new line (you should note that there will be an extra space at the end of the output).
The Python 3 Solution
Since the above does not work in Python 3, you can do this instead (again, without importing sys
):
def install_xxx(): print("Installing XXX... ", end="", flush=True) install_xxx() print("[DONE]")
The print function accepts an end
parameter which defaults to "\n"
. Setting it to an empty string prevents it from issuing a new line at the end of the line.
Related Posts:
- print variable and a string in python
- How to print to stderr in Python?
- How to print to stderr 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
- How do I specify new lines on Python, when writing on files?
- What is the purpose of the return statement?
- How to best print output to command window during a loop in Matlab?
- How can I do a line break (line continuation)?
- Is it possible to break a long line to multiple lines in Python? [duplicate]
- How can I do a line break (line continuation) in Python?
- 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 to read a file without newlines?
- How can I print variable and string on same line in Python?
- Printing variables in Python 3.4
- Easy pretty printing of floats?
- How to open every file in a folder
- How to print a linebreak in a python function?
- 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
- The value of _stdout is incorrect
- Python ‘If not’ syntax [duplicate]
- What is the maximum recursion depth in Python, and how to increase it?
- How to change the order of DataFrame columns?
- What does %s mean in a python format string?
- ImportError: No module named ‘tensorflow.python’
- How to access environment variable values
- python numpy ValueError: operands could not be broadcast together with shapes
- error: command ‘gcc’ failed with exit status 1 while installing eventlet
- Unzipping files in Python
- Python foreach equivalent
- Python NoneType object is not callable (beginner)
- _tkinter.TclError: no display name and no $DISPLAY environment variable
- What does if __name__ == “__main__”: do?
- How to fix IndexError: invalid index to scalar variable
- How to write inline if statement for print?
- proper name for python * operator?
- TypeError: cannot unpack non-iterable int objec
- Why are Python’s ‘private’ methods not actually private?
- Pandas DataFrame column to list
- Why does python use ‘else’ after for and while loops?
- Error: ” ‘dict’ object has no attribute ‘iteritems’ “
- Does Python have “private” variables in classes?
- Rename Pandas DataFrame Index
- What are metaclasses in Python?
- “E: Unable to locate package python-pip” on Ubuntu 18.04 [duplicate]
- What do I use for a max-heap implementation in Python?
- TypeError(“‘bool’ object is not iterable”,) when trying to return a Boolean
- Python – How to fix “ValueError: not enough values to unpack (expected 2, got 1)”
- Flask Template Not found
- Making a collatz program automate the boring stuff
- sprintf like functionality in Python
- Reverse / invert a dictionary mapping
- using pip3: module “importlib._bootstrap” has no attribute “SourceFileLoader”
- TypeError: unsupported operand type(s) for -: ‘list’ and ‘list’
- What’s the difference between a Python module and a Python package?
- How to overcome “datetime.datetime not JSON serializable”?
- AttributeError: ‘datetime’ module has no attribute ‘strptime’
- Where does this come from: -*- coding: utf-8 -*-
- SyntaxError invalid token
- TypeError: ‘type’ object is not iterable – Iterating over object instances
- How to check the version of scipy
- How to check if type of a variable is string?
- How to print colored text to the terminal
- Viewing all defined variables
- Does JavaScript support array/list comprehensions like Python?
- Difference between two dates in Python
- ImportError: No module named win32com.client
- Error message “Linter pylint is not installed”
- If statement for strings in python?
- How to create a numpy array of all True or all False?
- What is the quickest way to HTTP GET in Python?
- Pandas index column title or name
- Removing nan values from an array
- Python – While-Loop until list is empty
- ImportError: No module named xgboost
- How to properly create a HeatMap with Bokeh
- How to detect key presses?
- How do I merge lists in python? [duplicate]
- Python: What OS am I running on?
- creating a reverse method for a python list from scratch
- What does on_delete do on Django models?
- Convert floats to ints in Pandas?
- Unable to import tweepy module
- pandas comparison raises TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
- TypeError: got multiple values for argument
- How can I recover the return value of a function passed to multiprocessing.Process?
- Python Remove last char from string and return it
- NameError: name ‘reduce’ is not defined in Python
- numpy : calculate the derivative of the softmax function
- Difference between exit(0) and exit(1) in Python
- IOError: [Errno 32] Broken pipe when piping: `prog.py | othercmd`
- Show menu item description with line breaks