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 serhiy.storchaka
Recipients cheryl.sabella, serhiy.storchaka, terry.reedy
Date 2018-02-25.07:35:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1519544104.24.0.467229070634.issue32940@psf.upfronthosting.co.za>
In-reply-to
Content
For efficiency I suggest to initialize the mapping with dict.fromkeys(range(128), 'x') rather of an empty dict.

It is also possible to use regular expressions:

_trans = re.compile(r'''[^(){}\[]"'\\\n#]+''')
code = _trans.sub('x', code)
code = code.replace('{', '(')
code = code.replace('}', ')')
code = code.replace('[', '(')
code = code.replace(']', '(')
code = code.replace('\nx', '\n')

I didn't check what way is more efficient.
History
Date User Action Args
2018-02-25 07:35:04serhiy.storchakasetrecipients: + serhiy.storchaka, terry.reedy, cheryl.sabella
2018-02-25 07:35:04serhiy.storchakasetmessageid: <1519544104.24.0.467229070634.issue32940@psf.upfronthosting.co.za>
2018-02-25 07:35:04serhiy.storchakalinkissue32940 messages
2018-02-25 07:35:03serhiy.storchakacreate