If you want to learn to swim jump into the water. On dry land no frame of mind is ever going to help you.   - Bruce Lee.

Interactive interpreter

  • Just run python command in your terminal. You will be presented with an interactive interpreter.
  • >>> means the interpreter is ready to take input
  • Read, Eval, Print, Loop
  • It’s a good approach to have interactive interpreter open along with text editor while writing scripts, just to try things out on the go.
verax@humla $ python  # run python interpreter
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> print "I'm an interactive interpreter"
I'm an interactive interpreter
>>> 

Script interpreter

  • Write a script in text editor, save it with .py extension
  • python <script_name.py> to execute
  • Nano, Vim, Vi, Emacs are some decent commandline text editors.
  • Kate, Gedit, Notepad++ for people who like to work with GUI.
# contents of script
verax@untamed $ cat script.py 
print "I'm a script!!"

#Executing script
verax@untamed  $ python script.py 
I'm a script!!


Console

  • Python -c let’s you call the python binary directly, very handy when writing one liners.
# A simple onliner to build a NOP sled for memory exploits.
verax@humla $ python -c "import sys; sys.stdout.write('\x90'*40)"
����������������������������������������