How to use "while" within the command in -c option of python?

Etienne Robillard animelovin at gmail.com
Fri Oct 12 19:04:20 EDT 2012


On Fri, 12 Oct 2012 15:51:19 -0700
Herman <sorsorday at gmail.com> wrote:

>  python -c "import os; while True: print('hello')"
>  File "<string>", line 1
>  import os; while True: print('hello')
>                       ^
> SyntaxError: invalid syntax
> -- 
> http://mail.python.org/mailman/listinfo/python-list

You get a syntax error since you didn't used tabs indents in your string
which is normal for python AFAIK.



More information about the Python-list mailing list