CPO Guide

There are a few things to know about using the Pyret Editor. Let us help you navigate your way through it!

Getting Started

Connecting to Google Drive

Pyret is nice, in that, it allows you to connect it to your brown.edu Google Drive. This will allow you to save your files directly to Drive!

When you go to code.pyret.org, there is an option to 'Sign in' โ€“ click on that and log into your Brown email.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

If you are already in the Pyret Editor and want to connect it to Drive, click on the 'Connect to Google Drive' tab on the toolbar (top-left corner).

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Once your program / file is connected to your account, you will be able to find your files in a Drive folder called code.pyret.org.

Renaming and Downloading Pyret Files

Once you're signed in on Pyret, your toolbar will look like this:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Click on File > Rename to rename your .arr file. (Your file must be saved in order to rename it.)

To download your .arr file to your machine, click File > Download. This will save your file to your default download directory on your computer (it's probably a folder called Downloads).

Save Your Work!

Pyret sometimes auto-saves. DO NOT RELY ON THIS. Make sure you frequently save your work! You can click File > Save or use the keyboard shortcut Ctrl+s.

Definitions and Interactions Windows

There are four main features in the CPO:

  1. The left window:
  • Is called the Definitions window.
  • In this part of the CPO, you will provide Pyret the program that you want it to run. The program could consist of definitions (assignment of variables to expressions or functions), or expressions, or both. For example, this is a simple program that is defined in the left window:
circle(50, "solid", "red")
x = 9 + 5
hi = rectangle(100, 100, "solid", "black")
hi
  1. The Run button:
  • This run button will execute the program line by line.
  • When it encounters a definition, say x = 9 + 5, it will make sure that the right window (more information in part 3) knows such definition.
  • When it encounters an expression (or a name that is associated with an expression), it will execute the expression and display whatever is returned in the right window (more information in part 3).

For example, if you press "Run" on the program that is defined in part 1, the right window will display this:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

And when you type x in the new line in the right window, and press enter, it will print what is returned by x - this means that the Interactions window knows of everything that was defined in the Defitions window! More about the Interactions window in the section below.

  1. The right window:
  • is called the Interactions window
  • After the program is run: Displays whatever is returned by expression calls / calls of names that are associated with expressions from the Definitions window.
  • After the program is run: Knows of all the definitions in the in the Definitions window.
  • Allows you to keep on providing definitions and calling expressions / names associated with expressions after the program is run. For example, after we have executed the program in Part 1, in the new line in the Interactions window, you can typetriangle(50, "solid", "green") and press Enter, and your Interactions window should look like this:
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’
  • Similarly, you can define something, say y = x + 10, and Pyret will know what y is!
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’
  1. The Stop button:
  • There are some programs that Pyret will justโ€ฆ never finish executing (we will get to this in some (later) parts of the class), and in those cases, you could press the Stop button on the top right to stop the program! :)

Miscellaneous

Keyboard Shortcuts in the CPO

  • Save file: Ctrl+s
  • Run program: Ctrl+Enter
  • Auto-indent: Ctrl+A and then Tab will select all of your code and then auto-indent it for you! Be sure to run this before submitting any assignments, as style is a crucial part to your grade.

Design and Clarity and Stuff

After lecture 4, check out our Pyret Style and Design and Testing Guide! (Until lecture 4, you won't understand what's in this guide).