Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Handy tip if you’re parsing the output of a command in your programming language of choice:

  output = run(
    “list-cats”,
    “—format”,
    “%(name)s\x1f%(age)s\x1e”,
  )
  records = output.split(“\x1e”)
  cats = dict(
    r.split(“\x1f”)
    for r in records
  )
In reality it’s a bit fastidious to use RS and US. I tend to just use “\1” and “\2”.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: