Nov-11-2018, 03:59 AM
i would like to parse a line of python source instead of merely split it:
line = "blank=' '" parts = line.split() parts -> ["blank='","'"] pieces = ??parse??(line) pieces -> ["blank"."=","' '"]i want to get what pieces ends up with.
"a[0]=int(ab[16])+2" -> ["a","[","0","]","=","int","(","ab","[","16","]",")","+","2"]i need to parse some python source only one line at a time to make some edits by other scripts, although i am not sure how best to handle continuations. comments should be one big string. if white spaces are always included, that's ok.