Hacker News new | ask | show | jobs
by sgarland 722 days ago

  from string import capwords 
  result = capwords(string)
This does the split/capitalize/join dance, all in one.

The file example you gave could also be turned into a dict comprehension if desired. I’m on mobile, but I think this would work.

  result = { f:os.path.getsize(f) for f in glob.glob(ā€œ*ā€) if os.path.isfile(f) }