mirror of
https://github.com/kennethreitz-archive/howtopython.org.git
synced 2026-06-05 23:20:18 +00:00
_
This commit is contained in:
@@ -15,6 +15,19 @@ This is known as the Python interpreter, and is a REPL (Read–Eval–Print Loop
|
||||
Tricks
|
||||
++++++
|
||||
|
||||
``_`` Trick
|
||||
///////////
|
||||
|
||||
The ``_`` variable can be used to reference the last thing that was eval'd (e.g. automatically printed to the screen). For example::
|
||||
|
||||
>>> 1
|
||||
1
|
||||
>>> a = _
|
||||
>>> print(a)
|
||||
1
|
||||
|
||||
Very useful when using the interactive interpreter!
|
||||
|
||||
Bytecode Trick
|
||||
//////////////
|
||||
|
||||
|
||||
Reference in New Issue
Block a user