News for hackers. Stuff that matters.
Re:Ruby: A great language for shell scripts by sgarland on Sunday June 23, 2024 @09:15AM (#40767254)

  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) }

There are no comments on this comment yet.