top | item 29848220

(no title)

the_gigi | 4 years ago

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]

discuss

order

No comments yet.