What's the best way to go about parsing strings in Python? or Need help parsing strings in Python—any

20 Replies, 1796 Views

For quick-and-dirty parsing strings in Python, I love list comprehensions with `split()`.

Like: `[word.strip() for word in s.split(',') if word]`

Also, `str.partition()` is underrated—splits into 3 parts (before, sep, after). Super clean for simple splits.

Messages In This Thread



Users browsing this thread: 1 Guest(s)