2014年10月30日

Python Study (1) - Introduce Python

 

Why do I study Python  
    
     
Each program has advantage itself, why I study python program? This book(*1)
      give us several  advantages :

      1   Software quality : Python script is designed to be readable , reusable and
           maintainable.
      2   Developer productivity : We don't need to complie program.
      3.  Program portability :  It is portable and  run on any operating  system
      4.  Module :  many module is written in python
      5.  Easy : Easy to learn, easy to read, easy to maintain

User 
     Many companys adopt Python language to develop its products. such as :google,

      youtube, dropbox, google app engine...etc

What do python do          
         1. GUI 

         2. OS program
         3. Internet program
         4. Component Integration
         5, Database program


Python feature       
         1. Dynamic typing : you don't need to
declare a type or variable size in advance.
            Such as:  i = 0 ;
         2. Automatic memory management :  it   when the object is created
it can automatic create  and destroy

              object. python
         3. third-party utilities : developers  contribute many packages that is write in
             Python. To use these  save  your development time.
         4. easy to use : like human  syntax and simple read or write.
         5. free  :  It is free.

Download python             
              Download python install : https://www.python.org/downloads/

               Python 2.X  : it is a legacy.
               Python 3.X  : it is a evolution software and new features. such as: Unicode support.

               which version should I use : ref https://wiki.python.org/moin/Python2orPython3
             

       
    install

    Execute Python


 

  •  Python script execute          
               When the python code(.py) is executed first time, it will be into bytecode(.pyc).

                Bytecode is an implementation detail of the CPython interprete and low-level code.
                Bytecode makes execute faster than original source .
           
  • Python Virtual Machine(PVM)                  
             Python code is compiled to byte code(.pyc), PVM will execute the byte code.

              PVM is a engin of Python.



    • Setting variable environment
    1. Set your python environment variable
         
            Edit Path : C:\Python27\; C:\Python27\Scripts


        
         > python
     
        > ctrl + Z

      
        If you had installed many python versions, you can py -2 or  py -3 to switch   
         different  python version.

     
  •  Use IDLE
         1. Select IDLE , open Python Shell window    
     
          2. Execute python code
         


         3. To write python's script
        open New File.


        write a program

        Run Module or F5


        The script has executed and right to get answer
     
         

      
       
       
           
    Note:
           *1. Learning Python, 5th Edition, O'Reilly Media, ISBN:978-1-44935-573-9
  • 沒有留言:

    張貼留言