IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
22.2.2 Parsing Rules


22.2.2 Parsing Rules

When operating in non-POSIX mode, shlex will try to obey to the following rules.

  • Quote characters are not recognized within words (Do"Not"Separate is parsed as the single word Do"Not"Separate);
  • Escape characters are not recognized;
  • Enclosing characters in quotes preserve the literal value of all characters within the quotes;
  • Closing quotes separate words ("Do"Separate is parsed as "Do" and Separate);
  • If whitespace_split is False, any character not declared to be a word character, whitespace, or a quote will be returned as a single-character token. If it is True, shlex will only split words in whitespaces;
  • EOF is signaled with an empty string ('');
  • It's not possible to parse empty strings, even if quoted.

When operating in POSIX mode, shlex will try to obey to the following parsing rules.

  • Quotes are stripped out, and do not separate words ("Do"Not"Separate" is parsed as the single word DoNotSeparate);
  • Non-quoted escape characters (e.g. "\") preserve the literal value of the next character that follows;
  • Enclosing characters in quotes which are not part of escapedquotes (e.g. "'") preserve the literal value of all characters within the quotes;
  • Enclosing characters in quotes which are part of escapedquotes (e.g. """) preserves the literal value of all characters within the quotes, with the exception of the characters mentioned in escape. The escape characters retain its special meaning only when followed by the quote in use, or the escape character itself. Otherwise the escape character will be considered a normal character.
  • EOF is signaled with a None value;
  • Quoted empty strings ('') are allowed;

See About this document... for information on suggesting changes.