Comment

Comment by the_gigi

I often use split().

Instead of:

  s = ['a', 'b', 'c']
I'll type:

  s = 'a b c'.split()
For multiline lists where I want to get rid of leading whitespace I'll add lstrip():

  lines = """line 1
             line 2
             line 3
  """.split('\n')
  lines = [line.lstrip() for line in lines]
parent the_gigi 4 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton