Skip to Content
Getting Started with Processing.py
book

Getting Started with Processing.py

by Allison Parrish, Ben Fry, Casey Reas
May 2016
Beginner content levelBeginner
242 pages
4h 19m
English
Make: Community
Content preview from Getting Started with Processing.py

Appendix D. Variable Scope

The rule of variable scope in Python is defined simply: a variable created inside a function exists only inside that function. This means that a variable created inside setup() can be used only within setup(), and likewise, a variable declared inside draw() can be used only inside draw(). The exception to this rule is a variable declared outside of setup() and draw(). These variables can be used in both setup() and draw() (or inside any other function that you create). We call these variables global variables, because they can be used anywhere within the program. We call a variable that is used only within a single function a local variable. Following are a couple of code examples that further explain the concept. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Introduction to D3.js with React

Introduction to D3.js with React

Adam Janes

Publisher Resources

ISBN: 9781457186820Errata Page