Python editor compilation method description

Source: Internet
Author: User

From the Python editor, you can also call the compiler and its shared programs. In this way, the programmer can execute program operations without leaving the editor, the programmer will know the error during the compilation of the program instead of during the compilation.

There are two ways to run your program using Python-using an interactive interpreter with a prompt or using a source file. We will learn these two methods. Use the interpreter with a prompt to type python at the shell prompt of the command line to start the Python editor. Enter print 'Hello world' and press Enter. You can see the output word Hello World.

For Windows users, as long as you set the PATH variable correctly, you should be able to start the interpreter from the command line. Or you can choose to use the IDLE program. IDLE is the abbreviation of integrated development environment. Click Start> program> Python 2.3> IDLE (Python GUI ). Linux users can also use IDLE.

Note: >>> is the prompt of the Python statement you typed:

 
 
  1. $ python Python 2.3.4 (#1, Oct 26 2004, 16:42:40) 
  2. [GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2  
  3.  Type "help", "copyright", "credits" or "license" for more information. 
  4. >>> print 'hello world' hello world >>> 

Note that Python will output your output immediately in the next line! You just typed a Python statement. We use print (don't be surprised) to print the value you provided to it. Here we provide the text Hello World, which is quickly printed on the screen.

How to exit the Python editor prompt. If you are using Linux/BSD shell, press Ctrl-d to exit the prompt. If it is in Windows command line, press Ctrl-z and then press Enter. Select an editor before we start to write a Python program as a source file, we need an editor to write the source file. Selecting an editor is really important.

You can select an editor just like you can select a car you will buy. A good editor will help you easily write Python programs, make your programming journey more comfortable, and help you reach your destination more quickly and securely (to achieve your goal ).

One of the basic requirements of the editor is the syntax brightening function. With this function, different parts of your Python program are marked with different colors, so that you can better understand your program, to visualize its operation. If you are using Windows, we recommend that you use IDLE. IDLE has the syntax brightening function and many other functions, such as allowing you to run your program in IDLE.

Note: Do not use Notepad-it is a bad choice, because it does not have the syntax brightening function, and more importantly, it does not support text indentation. We will see that text indentation is extremely important to us. A good editor, such as IDLE (and VIM), will automatically help you do these tasks.

If you use Linux/FreeBSD, you have many options. If you are an experienced programmer, you must be using VIM or Emacs. Undoubtedly, they are two of the most powerful editors. You will benefit from using them to write your Python program. I personally use VIM to write most of my programs.

If you are a beginner in programming, you can use Kate, which is also one of my favorite editors. As long as you are willing to spend time learning to use VIM or Emacs, I strongly recommend that you learn either of them, because they are extremely helpful in the long run.

If you want to find other available editors, you can take a look at the detailed Python editor list and make your choice. You can also use Python IDE (integrated development environment ). For more information, see the Python-supported IDE list. Once you write a large Python program, the IDE is really useful.

  1. Introduction to Python system files
  2. How to correctly use Python Functions
  3. Detailed introduction and analysis of Python build tools
  4. Advantages of Python in PythonAndroid
  5. How to Use the Python module to parse the configuration file?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.