On Friday, May 30, 2014 11:34:36 AM UTC+5:30, Rustom Mody wrote:
> On Friday, May 30, 2014 6:22:24 AM UTC+5:30, Chris Angelico wrote:
> > Since lines are so critical to Python syntax, I'm a little surprised
> > there's no majorly obvious solution to this... or maybe I'm just
> > blind.
> > Problem: Translate this into a shell one-liner:


> > import os
> > for root, dirs, files in os.walk("."):
> >     if len(dirs + files) == 1: print(root)

Heres a (poooor) approx

$ python -c 'import os, pprint; pprint.pprint ([ r for r, d, f in os.walk(".") 
if len(d+f) != 1])'


Mysterious that print after a ; is fine whereas for is not



> Anyways...

> I thought when one signs up for python one has to sign an affidavit
> saying:
> "I shall not write one-liners\n" * 100

I hope youve signed it by now <wink>
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to