alphanumeric
alphanumeric

Reputation: 19359

How to enter a new line using Python IDLE

On 31:43 of Python 3 Metaprogramming youtube video David Beazley advances to a new line of Python IDLE (31:43) without forcing an execution. What keyboard key or combinations of keys is used to make it work?

Upvotes: 0

Views: 5227

Answers (3)

shaahiin
shaahiin

Reputation: 1385

If you open an indent block in the IDLE, hitting Enter will not execute the line.

>>> class A(Base):
...     

Hitting Enter after an empty line will execute the whole block of code.

>>> class A(Base):
...     pass
... 
>>>

Upvotes: 3

jackdewinter
jackdewinter

Reputation: 50

In the video you linked, David is not using Python IDLE (Integrated Development Learning Environment), which is an instance of an IDE, he is using the Python Interpreter which is a binary executable for the interactive Python shell for executing python statements.

In all of these interactive interpreters, when you have an expected indent, usually in loops, conditions and in your case a class, the line ending in a colon : will not execute when you hit the Enter key it will allow you to keep typing in the next line until you hit Enter twice.

Upvotes: -1

chepner
chepner

Reputation: 532003

He's not typing anything special; Idle doesn't end the class definition (started by the class keyword) until you enter a blank line.

Upvotes: 3

Related Questions