This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author berker.peksag
Recipients berker.peksag, docs@python, evan_, marco.buttu, r.david.murray, vinay.sajip
Date 2017-01-07.06:49:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1483771783.19.0.436198408517.issue29133@psf.upfronthosting.co.za>
In-reply-to
Content
I'd probably write it without the for loop:

    text = "a && b; c && d || e; f >'abc'; (def \"ghi\")"

    result = shlex.shlex(text)
    print(f"Old behavior: {list(result)}")

    result = shlex.shlex(text, punctuation_chars=True)
    print(f"New behavior: {list(result)}")

Or just:

    >>> import shlex
    >>> text = "a && b; c && d || e; f >'abc'; (def \"ghi\")"
    >>> list(shlex.shlex(text))
    ['a', '&', '&', 'b', ';', 'c', '&', '&', 'd', '|', '|', 'e', ';', 'f', '>', "'abc'", ';', '(', 'def', '"ghi"', ')']
    >>> list(shlex.shlex(text, punctuation_chars=True))
    ['a', '&&', 'b', ';', 'c', '&&', 'd', '||', 'e', ';', 'f', '>', "'abc'", ';', '(', 'def', '"ghi"', ')']

(Adding Vinay to nosy list to get his feedback since he wrote the original example.)
History
Date User Action Args
2017-01-07 06:49:43berker.peksagsetrecipients: + berker.peksag, vinay.sajip, r.david.murray, docs@python, marco.buttu, evan_
2017-01-07 06:49:43berker.peksagsetmessageid: <1483771783.19.0.436198408517.issue29133@psf.upfronthosting.co.za>
2017-01-07 06:49:43berker.peksaglinkissue29133 messages
2017-01-07 06:49:42berker.peksagcreate