Type More Quickly and Accurately
00:00 Type More Quickly and Accurately. When using the regular Python REPL, your coding speed is directly limited by how quickly you can type and how well you remember the names of functions, arguments, and so on.
00:27 All these features can save you a lot of typing and help avoid annoying typos, making you faster and more productive at work. As soon as you start typing something, byython will look up Python keywords, built-ins, globals, and your current lexical scope according to the LEGB rule to find objects with matching names.
00:48 It matches names that begin with a specific sequence of characters, so typing more characters will narrow down the results. It will then display a list of relevant suggestions in alphabetical order.
In this example, you are getting suggestions for the
pass statement, a few built-in functions such as
print(), and two user-defined variables called
program_scope that were defined earlier in the current global scope.
but that’s not all. Code suggestions go hand in hand with auto-completion, which is another useful feature in many editors, including bpython. Essentially, it can write the remaining code for you when there’s no ambiguity about what you’re trying to type. In this example, the correct variable,
program, has been selected and can be completed by hitting Enter.
On the other hand, if there’s only one suggestion left and you haven’t finished typing the whole name, then you can press Tab to have Python automatically complete the remaining part as seen here with
print(), which can then be completed by typing in the normal way.
02:36 A lesser-known fact about Python’s auto-completion mechanism is that it understands your file system. In other words, when you start typing a string literal that resembles a file path and you hit Tab, Python will list all the files and folders that match the string that you’ve typed so far.
Become a Member to join the conversation.