How to tell to shlex that if the character ; is found, then, don’t split anything anymore? Example: should give instead of [“hello”, “column number 2”, “foo”, “;”, “bar”, “baz”]. More generally, is there a way to define “comment” separators with shlex? i.e. should give Answer The shlex parser provides an option for specifying the comment character(s), but it’s not