Printing list elements on separate lines in Python
Solution 1:
print("\n".join(sys.path))
(The outer parentheses are included for Python 3 compatibility and are usually omitted in Python 2.)
Solution 2:
Use the print function (Python 3.x) or import it (Python 2.6+):
from __future__ import print_function
print(*sys.path, sep='\n')
Solution 3:
Another good option for handling this kind of option is the pprint
module, which (among other things) pretty prints long lists with one element per line:
>>> import sys
>>> import pprint
>>> pprint.pprint(sys.path)
['',
'/usr/lib/python27.zip',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/lib/python2.7/site-packages',
'/usr/lib/python2.7/site-packages/PIL',
'/usr/lib/python2.7/site-packages/gst-0.10',
'/usr/lib/python2.7/site-packages/gtk-2.0',
'/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
'/usr/lib/python2.7/site-packages/webkit-1.0']
>>>