Skip to content

Instantly share code, notes, and snippets.

@tsal
Last active August 31, 2019 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsal/2a683999492784f0e86998858cb656cf to your computer and use it in GitHub Desktop.
Save tsal/2a683999492784f0e86998858cb656cf to your computer and use it in GitHub Desktop.
strings are first class
>>> ",".join("get all the words as a list then make them a csv".split())
'get,all,the,words,as,a,list,then,make,them,a,csv'
"inline string separated by spaces".split()
",".join("get all the words as a list then make them a csv".split())
>>> long = "this is a longsep string with sep as a separator"
>>> short = "strings,are,first,class,in,python"
>>>
>>> print(long.split("sep"))
['this is a long', ' string with ', ' as a ', 'arator']
>>>
>>> print(short.split(","))
['strings', 'are', 'first', 'class', 'in', 'python']
long = "this is a longsep string with sep as a separator"
short = "strings,are,first,class,in,python"
print(long.split("sep"))
print(short.split(","))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment