Skip to main content
Don't use code formatting on non-code. Typo.
Source Link
wjandrea
  • 34.2k
  • 10
  • 71
  • 108

Other method is to unpack all values in print and use new linenew line as separator

python -c 'import sys; print(*sys.path, sep="\n")'

I'm not sure but print() may have limit to 255 arguments (or maybe it had it in older versions)
but sys.path is shorter.


After ; one-liner doesn't allow for some constructions which normally need indentations:, like for-loop, while-loop, if/elif/else, try/except

Other method is to unpack all values in print and use new line as separator

python -c 'import sys; print(*sys.path, sep="\n")'

I'm not sure but print() may have limit to 255 arguments (or maybe it had it in older versions)
but sys.path is shorter.


After ; one-liner doesn't allow for some constructions which normally need indentations: like for-loop, while-loop, if/elif/else, try/except

Other method is to unpack all values in print and use new line as separator

python -c 'import sys; print(*sys.path, sep="\n")'

I'm not sure but print() may have limit to 255 arguments (or maybe it had it in older versions)
but sys.path is shorter.


After ; one-liner doesn't allow for some constructions which normally need indentations, like for-loop, while-loop, if/elif/else, try/except

added 14 characters in body
Source Link
furas
  • 150.2k
  • 12
  • 128
  • 177

Other method is to unpack all values in print and use new line as separator

python -c 'import sys; print(*sys.path, sep="\n")'

I'm not sure but print() may have limit to 255 arguments (or maybe it had it in older versions)
but sys.path is shorter.


After ; one-liner doesn't allow for some constructions which normally need indentations: like for-loop, while-loop, if/elif/else, try/except

Other method is to unpack all values in print and use new line as separator

python -c 'import sys; print(*sys.path, sep="\n")'

I'm not sure but print() may have limit to 255 arguments (or maybe it had it in older versions)
but sys.path is shorter.


After ; one-liner doesn't allow for some constructions which normally need indentations: like for-loop, while-loop, if/elif/else

Other method is to unpack all values in print and use new line as separator

python -c 'import sys; print(*sys.path, sep="\n")'

I'm not sure but print() may have limit to 255 arguments (or maybe it had it in older versions)
but sys.path is shorter.


After ; one-liner doesn't allow for some constructions which normally need indentations: like for-loop, while-loop, if/elif/else, try/except

added 42 characters in body
Source Link
furas
  • 150.2k
  • 12
  • 128
  • 177

Other method is to unpack all values in print and use new line as separator

python -c 'import sys; print(*sys.path, sep="\n")'

I'm not sure but print() may have limit to 255 arguments but(or maybe it had it in older versions)
but sys.path is shorter.


After ; one-liner doesn't allow for some constructions which normally need indentations: like for-loop, while-loop, if/elif/else

Other method is to unpack all values in print and use new line as separator

python -c 'import sys; print(*sys.path, sep="\n")'

I'm not sure but print() may have limit to 255 arguments but sys.path is shorter.

Other method is to unpack all values in print and use new line as separator

python -c 'import sys; print(*sys.path, sep="\n")'

I'm not sure but print() may have limit to 255 arguments (or maybe it had it in older versions)
but sys.path is shorter.


After ; one-liner doesn't allow for some constructions which normally need indentations: like for-loop, while-loop, if/elif/else

Source Link
furas
  • 150.2k
  • 12
  • 128
  • 177
Loading