👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
I"m using Python with -c
to execute a one-liner loop, i.e.:
$ python -c "for r in range(10): print "rob""
This works fine. However, if I import a module before the for loop, I get a syntax error:
$ python -c "import sys; for r in range(10): print "rob""
File "<string>", line 1
import sys; for r in range(10): print "rob"
^
SyntaxError: invalid syntax
Any idea how this can be fixed?
It"s important to me to have this as a one-liner so that I can include it in a Makefile.
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from Executing multi-line statements in the one-line command-line?, check other code Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano Executing multi-line statements in the one-line command-line?
- Deutsch Executing multi-line statements in the one-line command-line?
- Français Executing multi-line statements in the one-line command-line?
- Español Executing multi-line statements in the one-line command-line?
- Türk Executing multi-line statements in the one-line command-line?
- Русский Executing multi-line statements in the one-line command-line?
- Português Executing multi-line statements in the one-line command-line?
- Polski Executing multi-line statements in the one-line command-line?
- Nederlandse Executing multi-line statements in the one-line command-line?
- 中文 Executing multi-line statements in the one-line command-line?
- 한국어 Executing multi-line statements in the one-line command-line?
- 日本語 Executing multi-line statements in the one-line command-line?
- हिन्दी Executing multi-line statements in the one-line command-line?
Vigrinia | 2023-01-27
Thanks for explaining! I was stuck with Executing multi-line statements in the one-line command-line? for some hours, finally got it done 🤗. Will get back tomorrow with feedback
Massachussetts | 2023-01-27
COM PHP module is always a bit confusing 😭 Executing multi-line statements in the one-line command-line? is not the only problem I encountered. I am just not quite sure it is the best method
Munchen | 2023-01-27
Maybe there are another answers? What Executing multi-line statements in the one-line command-line? exactly means?. I just hope that will not emerge anymore