[Python-ideas] Open parenthesis in REPL completion

Stephen J. Turnbull turnbull.stephen.fw at u.tsukuba.ac.jp
Thu Apr 25 07:27:34 EDT 2019

Steven D'Aprano writes:

 > But having the opening bracket auto-added is a small satisfaction,

I'm not going to weigh in on this feature: I can see it either way.
What I don't get is why we don't go full metal Emacs, by adding the
corresponding end delimiter, and backspace.  In each line below the
RHS are the characters typed, the LHS the characters inserted, and the
vertical bar | represents the position of the insertion cursor:

(   => (|)
[   => [|]
{   => {|}
"   => "|"
""  => ""|        # fooled ya, didn't I?  Could do it for parens too.
""" => """|"""
''  => ''|
''' => '''|'''

There may be others.  And bonus points for DTRT in strings and
comments (especially for "'", since it's used as apostrophe in
non-program text).

Once I got used to it, I found it really cut down on the annoyance of
counting parens and making sure start parens weren't paired with end
braces and similar errors.  YMMV, of course.


More information about the Python-ideas mailing list