In unix shells you can literally use a new line. Or is that only bash? -- Devin
On Fri, May 30, 2014 at 2:11 PM, Duncan Booth <duncan.booth@invalid.invalid> wrote: > Chris Angelico <ros...@gmail.com> wrote: > >> Problem: Translate this into a shell one-liner: >> >> import os >> for root, dirs, files in os.walk("."): >> if len(dirs + files) == 1: print(root) >> > > This is one area where Windows seems to do better than Linux shells: > > PS C:\python33> python -c "import os`nfor root, dirs, files in > os.walk('.'):`n if len(dirs + files) == 1: print(root)`n" > .\Doc > .\Lib\concurrent\__pycache__ > .\Lib\curses\__pycache__ > ... > > The `n shell escaped newline is interpreted well before Python runs. > > Also the multiline version works and in Powershell ISE up-arrow pulls it back > as a > single unit for easy editing: > > PS C:\python33> python -c @" > import os > for root, dirs, files in os.walk('.'): > if len(dirs + files) == 1: print(root) > "@ > .\Doc > .\Lib\concurrent\__pycache__ > .\Lib\curses\__pycache__ > ... and so on ... > > > -- > Duncan Booth > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list