http://www.skillbrew.com /Skillbrew Talent brewed by the industry itself Python interpreter and files Pavan Verma @YinYangPavan Founder, P3 InfoTech Solutions Pvt. Ltd. 1 Python Programming Essentials
© SkillBrew http://skillbrew.com Interpreter  An interpreter is a computer program which executes other programs.  Python interpreter carries out instructions in your program.  Python interpreter can be used interactively to test out instructions on the fly. A good way to try little experiments. 2
© SkillBrew http://skillbrew.com >>> 'hey' * 2 'heyhey' >>> 2 + 2 4 >>> 9/2 4 >>> 9//2 4 >>> colors = ['orange', 'red', 'yellow'] >>> colors ['orange', 'red', 'yellow'] >>> for color in colors: color 'orange' 'red' 'yellow' Try things in interpreter and it will give back results immediately. No need to write separate programs to learn new features. 3
© SkillBrew http://skillbrew.com pyc files .pyc files are "Compiled" Python files”. Once a file is compiled, Python executes the compiled file. .pyc files are created when the .py file’s modification time is different. It’s good to keep .pyc files around, speeds up execution when a program is ran again by avoiding compilation. Python File *.py Bytecode *.pyc Interpreter uses *.pyc file 4
© SkillBrew http://skillbrew.com A look under the hood  The python interpreter consists of two parts: • A python bytecode compiler • A virtual machine which executes Python bytecode. Source: http://trizpug.org/Members/cbc/ wyntkap/compiler.html 5
© SkillBrew http://skillbrew.com A look under the hood (2) • The bytecode compiler accept human readable python expressions and statements as input. • And produces machine-readable python bytecode as output. Source: http://trizpug.org/Members/cbc/ wyntkap/compiler.html 6
© SkillBrew http://skillbrew.com A look under the hood (3) • The virtual machine accepts the python bytecode as input. • And executes the virtual machine instructions represented by the bytecode. Source: http://trizpug.org/Members/cbc/ wyntkap/compiler.html 7
© SkillBrew http://skillbrew.com Resources  http://trizpug.org/Members/cbc/wyntka p/compiler.html 8

Python Programming Essentials - M29 - Python Interpreter and Files

  • 1.
    http://www.skillbrew.com /Skillbrew Talent brewed bythe industry itself Python interpreter and files Pavan Verma @YinYangPavan Founder, P3 InfoTech Solutions Pvt. Ltd. 1 Python Programming Essentials
  • 2.
    © SkillBrew http://skillbrew.com Interpreter An interpreter is a computer program which executes other programs.  Python interpreter carries out instructions in your program.  Python interpreter can be used interactively to test out instructions on the fly. A good way to try little experiments. 2
  • 3.
    © SkillBrew http://skillbrew.com >>>'hey' * 2 'heyhey' >>> 2 + 2 4 >>> 9/2 4 >>> 9//2 4 >>> colors = ['orange', 'red', 'yellow'] >>> colors ['orange', 'red', 'yellow'] >>> for color in colors: color 'orange' 'red' 'yellow' Try things in interpreter and it will give back results immediately. No need to write separate programs to learn new features. 3
  • 4.
    © SkillBrew http://skillbrew.com pycfiles .pyc files are "Compiled" Python files”. Once a file is compiled, Python executes the compiled file. .pyc files are created when the .py file’s modification time is different. It’s good to keep .pyc files around, speeds up execution when a program is ran again by avoiding compilation. Python File *.py Bytecode *.pyc Interpreter uses *.pyc file 4
  • 5.
    © SkillBrew http://skillbrew.com Alook under the hood  The python interpreter consists of two parts: • A python bytecode compiler • A virtual machine which executes Python bytecode. Source: http://trizpug.org/Members/cbc/ wyntkap/compiler.html 5
  • 6.
    © SkillBrew http://skillbrew.com Alook under the hood (2) • The bytecode compiler accept human readable python expressions and statements as input. • And produces machine-readable python bytecode as output. Source: http://trizpug.org/Members/cbc/ wyntkap/compiler.html 6
  • 7.
    © SkillBrew http://skillbrew.com Alook under the hood (3) • The virtual machine accepts the python bytecode as input. • And executes the virtual machine instructions represented by the bytecode. Source: http://trizpug.org/Members/cbc/ wyntkap/compiler.html 7
  • 8.
    © SkillBrew http://skillbrew.com Resources http://trizpug.org/Members/cbc/wyntka p/compiler.html 8