Skip to Content
Jython Essentials
book

Jython Essentials

by Samuele Pedroni, Noel Rappin
March 2002
Beginner
300 pages
8h 22m
English
O'Reilly Media, Inc.
Content preview from Jython Essentials

Chapter 3. Jython Control Flow

Control statements include conditionals such as if, and loop constructs such as for and while. They form the structure that holds a program together and shapes its behavior. Although the basics of conditionals and loops are similar across a wide variety of programming languages, each language has its own specific implementation. Coming from Java to Python, you will find the basic statements familiar, but some of the details will be new. In this chapter, we will tour the ways in which Python manages flow of control, including the use of indentation to mark block boundaries.

Statements and Expressions

A Python program consists of a series of statements. A statement can be:

  • An expression combining variables and operators, which may include function or method calls

  • An assignment

  • One of several keyword statements, such as if, for, or try

The following are all valid statements:

1 + 2 * 3

range(2, 3)

inputFile.close( )

if x == None: return

In Python, simple statements are normally separated by the end of a line (any operating system’s end-of-line combination will work). However, Python will allow a statement to continue beyond the end of a line if there is an open parenthesis, bracket, brace, or triple-quote string. Such a statement can continue over any number of lines until the delimiter is closed. A statement can also be continued to the next line by ending it with a backslash \. The backslash only allows the statement to be continued for one more line; to continue ...

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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Swing for Jython: Graphical Jython UI and Scripts Development using Java Swing and WebSphere Application Server

Swing for Jython: Graphical Jython UI and Scripts Development using Java Swing and WebSphere Application Server

Robert Gibson
Introduction to JVM Languages

Introduction to JVM Languages

Ramasubramanian Sankar, Vincent van der Leun
Oracle Essbase & Oracle OLAP

Oracle Essbase & Oracle OLAP

Michael Schrader, Dan Vlamis, Mike Nader, Chris Claterbos, Dave Collins, Mitch Campbell, Floyd Conrad

Publisher Resources

ISBN: 9781449397364Errata Page