Editors, Scripts, and Miscellaneous Screen Reader Configuration

While you can certainly write scripts in a notepad (I have for a year or so), there are a multitude of editors available for working with Python. Said tools allow for features like autoindentation, autocompletion, and can go as far as supporting type annotations and providing helpful hints as you are calling functions. If this sounds like gibberish, don't worry. You can always switch to something new later. Unfortunately, do to the extensive amount of options, this guide will only list the available tools and provide comments as necessary rather than give details on installation and setup for each product.

Editor and IDE listing

  • Notepad II
  • Notepad ++, provides autocompletion and autoindentation while converting tabs into four spaces (adjustable). A quick search for "Python extension for notepad ++" yielded this link for completion of standard Python library functions. See this link on how to run Python using Notepad ++ without needing to resort to commandline.
  • EdSharp, lacks the ability to save empty files but works well otherwise
  • VSCode, has a medium learning curve and requires an extension like Microsoft Python in exchange for providing excellent debugging tools, integration with Git, indentation, and completion.
  • PyCharm, may require Java and Java Access Bridge. Be sure that the version of Java you install matches that of your system, I.e, 64-bit installation for a 64-bit machine. Upon launch, PyCharm should prompt you to turn on screen reader mode if you are running any assistive technology, I.e, NVDA or Jaws.
  • Visual Studio Community, big and clunky at times and does not guarantee accessibility of its profiler and debugger, but works well when it does. Note that you will have to install this and the C++ Desktop Development extension should you choose to Cythonize your code. Also note that just like with VSCode, you will have to install a seperate extension to enable Python support, though this time the said package is in the installer itself. If you experience lag with NVDA while using the IDE, try turning on "Enable selective registration for UI Automation events and property changes" in the advanced section of your NVDA preferences. It may or may not help.

Running Code From the Commandline

Regardless of what option you chose, knowing how to interface with the Python interpreter is a valuable skill. If you want to test something out, whether a particular standard library module has a specific function, for instance, the interpreter can be of grate help. If you are not sure of what a commandline is, a quick skim through this article should clear up the mystery.

Great, How Do I Open and Use This Thing?

To open up your commandline, press windows+r to bring up the run dialog, type cmd, and hit enter. You should now see something like the following:

Microsoft Windows [Version 10.0.19041.685]
(c) 2020 Microsoft Corporation. All rights reserved.

C:\Users\yourUsername>

You are now in the command prompt and the system is waiting for your input. If you type "dir" without the quotes, you will get the listing of all the files and folders within your directory. Typing a filename by itself, such as some_file.txt, will cause said file to open within its associated app, Notepad ++ in my case. Typing "cd directory_name" will cause you to move to the desired directory. Typing "cd .." will move you back to the previous folder. Think of it as a tree where each directory is a branch and it holds other branches (directories) which you could move to and leaves (files) which you can only look at or manipulate. So, using my analogy, typing "cd branch_name" moves you to said branch, and typing "cd .." will cause you to return to the branch your current branch is connected to. This is not entirely accurate (the branches don't have to be linked in order for you to be able to move to them), but this should help you understand how the commandline works.
The above paragraph may seem slightly confusing, so I will provide a practical example. Suppose you open up your commandline, type in "dir", and see that you have a folder called some_awesome_thing. Not knowing what it contains, you type "cd some_awesome_thing" and watch as your path is updated to be "C:\Users\yourUsername\some_awesome_thing>". Typing in "dir" once again shows you that there is a single folder, creatively called thing, inside this directory. Your curiosity still unsatisfied, you type in "cd thing" and once again ping the directory for its contents by typing "dir". This time, you only see a file, called run_me.py. Finally satiated with said knowledge, you type "cd .." twice to return you back to your starting point. Note that you could also have typed "cd c:\users\yourUsername", but I chose to use the first method do to its simplisity.

Wait, Do I Have To Type All These Names?

No, you certainly do not. The commandline has a nice feature where you can type in a part of the desired path and press tab to have it fill out the rest for you. You can keep pressing tab and cycle through the available suggestions. In the previous example, you could have just typed in "cd ", do note the trailing space after cd, and pressed tab to go through all of the available directories rather than use dir to find out what is inside your folders.

Why the Underscores?

I chose to use underscores (_) to remove the necessity of surrounding your arguments with quotes. The commandline will equally accept some_awesome_thing or some awesome thing, but it will require the latter to be surrounded in quotation marks, I.e, "some awesome thing"

A quick note

I have been surrounding the commands dealing with commandline input with quotation marks, but this is not how you will see cmd input being notated on the internet. Typically you will see a dollar sign ($) before the desired command, I.e:

$dir
$cd some_awesome_thing

Going forward, this is how I will notate commandline input as well. I feel like this is a given, but if you are copying the example commands, remove the dollar sign in order to make them work.

Back to Your Regularly Scheduled Conversation With the Interpreter

After getting familiar with the commandline, we can now continue to discuss how to run code outside of special editors. As I have previously mentioned, Python interpreter can help out with quick testing, so that is what we will begin with. Open up your commandline and type in the following:

$python

You should now see something similar to the following text:

Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

If you get text like 'python' is not recognized as an internal or external command, operable program or batch file, refer to the previous chapter for some pointers regarding adjustment of your environment variables.

Printing Text

Before we shut down the interpretor, let's say you wanted to verify that the print function works as expected. Type in the following into your console (Don't leave anything out, parentheses and quotes are important!).

print("Hello, World!")

If you get silence as your output and are using NVDA, press NVDA+5 to turn on reporting of dynamic content changes and try again. If you are using Jaws, reviewing the screen is a matter of scrolling with your Jaws cursor (JAWS+RightBracket). You should now get the classic introduction to programming message. If you get an error, make sure that all the quotes and parentheses are present and that you didn't accidentally misspell print. If it still doesn't work... well, I hope you had fun, because the world is about to end and Python refuses to speak do to the impending apocalypse.
Regardless of the outcome, to close the interpreter, you can simply type

exit()

or

quit()

and you will be returned to the comforts of the command prompt.

Running Larger Code Chunks

The interactive console is great for quick tests, but it ddoes not work too well for larger projects. Fortunately, Python provides an easy way to run large scripts from the commandline. Start by opening your command prompt and navigating to the desired directory where you wish for the script to reside in and type in the following:

$echo.>your_script_name.py

This creates an empty file, your_script_name.py, which you can then open with your desired editor. Edit your file to look like the following:

print("Hello, Commandline!")

After saving the file, go back to your command prompt and type the following:

$python your_script_name.py

You should get the output of "Hello, Commandline!". If you are greeted with silence and are using NVDA, make sure you turned on the reporting of dynamic content changes by hitting NVDA+5. If that still does not work, read on to see how to review your screen

Reviewing the Screen

At times, your script may exit silently without giving you any output to work with. This is do to your speech being interrupted as your focus switches back to the commandline. To that end, here is the solution to seeing silent errors

Using NVDA

  • If you are using the laptop layout, use NVDA+PageUp and NVDA+PageDown until you hear "Object review". After object review has been selected, use NVDA+Up and NVDA+Down arrow keys to review the command prompt screen. Your cursor typically starts at the bottom and thus you may need to scroll upwards to see the error and the traceback.
  • If you are using the desktop layout, use NVDA+Numpad7 and NVDA+Numpad1 until you hear "Object review". After object review has been selected, use Numpad7 and Numpad9 to review the command prompt screen. Your cursor typically starts at the bottom and thus you may need to scroll upwards to see the error and the traceback.

Using Jaws

You can use the standard Jaws cursor (JAWS+RightBracket) to review the last couple of messages. (Thanks Defender for supplying this tip)

Miscellaneous Settings

Indentation

It is very common to see complaints about the necessity to keep track of tabs and spaces. Fortunately, both NVDA and Jaws screen readers provide a solution to this issue.

Using NVDA

To turn on indentation reporting, go into your NVDA preferences, click on settings, scroll down to document formatting, and press Alt+I. This will bring you to a combo box where you can choose how NVDA notifies you of indention (speech, tones, or both). After selecting your desired method, scroll down and press apply before clicking okay to close the settings dialog.

Using Jaws (Thanks Defender for supplying this tip)

Method 1
  • Go to JAWS settings center (JAWS Key plus 6) and either set it for the current application only or use control shift D to make it system wide.
  • Hit shift tab and Type "indent" into the search box.  The only option which comes up is the one you want. You may also want to go into the settings center search box and type "speech and sound" for the speech and sounds category.  There you can change the default scheme by pressing space until it matches the number of spaces that your code editor considers to be a tab if it doesn't seem to be reporting properly.
Method 2

When within the window of your editor, use JAWS Key plus V, shift tab and type "indent" again, then set the option to indicate. You may also want to go into the settings center search box and type "speech and sound" for the speech and sounds category.  There you can change the default scheme by pressing space until it matches the number of spaces that your code editor considers to be a tab if it doesn't seem to be reporting properly.

Testing Indentation

To verify that indentation reports work, read through the following piece of Python code.

def main():
    print("I will now count to 10!")
    for i in range(1, 11):
        print(i)
    print("Alright, all done now!")

main()

Symbol reports

It is common to need to find a mistake in regarding unmatched parentheses within Python code. NVDA and Jaws provide a variety of symbol reporting options to assist in this endeavor. For NVDA, you can toggle through said choices with NVDA+P. For Jaws, you need to navigate to the settings center and search for customize punctuation (Thanks Defender for supplying this tip). I personally find the most option to be the most helpful (I think that reading out commas and periods is unnecessary), but you may differ in that regard. To that end, the code below can be used as a testing method for the various settings

def print_3d_list():
    matrix = [[[k for k in range(10)] for j in range(10)] for i in range(10)]
    for i in range(len(matrix)):
        for j in range(len(matrix[i])):
            for k in range(len(matrix[i][j])):
                print("Current coordinates: (%d, %d, %d)" % (i, j, k))
                print(f"Current element: {matrix[i][j][k]}")

print_3d_list()

That's It!

Now that you have an editor and know how to use Python from the commandline, you can proceed to the next section where I have compiled a list of tutorials for you to get started programming. I certainly don't recommend going through all of them at once, better to stick to one method of learning unless you get stuck, but if something does not make sense, feel free to try something else or switch to something new. Just because you chose a specific book or course does not mean that you have to be purely devoted to its methods of teaching. If an explanation seems confusing, chances are that there is a better one out there and you just need to look for it

Attribution

This section would not be complete without input from the community. In particular, Defender provided instructions regarding Jaws commands for indentation, symbol reporting, and reviewing commandline output. If the instructions here are unclear, his original replies are located in this thread, posts 3 and 5.