A summary of Python interactive skills

Source: Internet
Author: User

The Python interpreter supports a variety of Python interactive executions ., This method is very helpful when debugging a piece of code, because you do not need to put the Python source code into the Python script and execute the script program, this makes it easy to integrate the interaction mode of the Python interpreter into Eclipse.

The External Tool Startup Program Configuration window is displayed. Select "Program" in the deployments list and click "New" to create a New configuration. Name the configuration as "pythonInteractive", set the Location to point to your Python interactive mode, and then pass "-I" as a unique parameter.

Under the Common tab, select the check box to display the configuration in the External Tools favorites menu. To Run the starter created in Eclipse, choose Run> External Tools> pythonInterpreter.

The output of the Python interpreter is displayed in the Console view. You can enter and execute Python commands in the Console, just like running Python from the command line. To import and use a module in interactive mode, you must add the module location to the PYTHONPATH environment variable. The difference between running Python in the Eclipse Console and using command lines is that you cannot enable the command history feature through the up and down direction keys), because the Eclipse Console will explain these keys by itself.

Python will automatically compile the module as needed. This means that Python interactive developers generally do not have to explicitly edit modules. Even so. Sometimes it is very useful to compile Python code manually. At the same time, there are many other aspects in the construction and deployment process that can be automatically implemented. This is also the application of building tools.

I will focus on Apache Ant from the Java programming world. This tool can be widely used in Python development. Apache Ant is a de facto standard building tool in the Java programming field. It is lighter, better integrated with Java technology, and can be used to replace other building tools. Ant can run on any platform that supports the Java programming language.

Although most of the building features Ant we need are provided, if Ant is to be used as a Python interactive building tool, some key Python-related features are required. I have developed several customized Ant plug-ins called task in Ant's line), which can provide Python-specific features required for building Python.

Ant uses XML as the description format. Build files are organized as the targets to be executed. Each target may depend on other goals. Ant will execute any desired target based on the target you requested and a set of dependency targets.

Each target may contain any number of Ant tasks, and the Ant task actually executes the work of the target. Ant has many built-in tasks, such as compiling Java code, generating documents, manipulating files and directories. At the same time, third parties provide many additional tasks.

  • Summary of Python programming skills
  • Complete parsing of Python Design Language Features
  • Python programming language with simplified read flexibility
  • Python version hodgedge
  • How to handle Python exceptions

Installing the Python Ant library I will introduce the basics of Ant build scripts and Python Ant tasks by creating a build script for the feedparser project. To use Python Ant tasks, you need to download and install the Java libraries that contain these tasks. First, download the Python Ant job library pyAntTasks. jar from the URLs listed in the references section ).

Then, copy the JAR file to the lib directory under the Ant plug-in of Eclipse. This should be a subdirectory under the Eclipse installation directory, such as plugins/org. apache. ant_1.5.3. After the Python Ant job library is copied, you must enable the library in Eclipse. Select Window> Preferences, and then select Ant> Runtime.

Expand Ant Home Entries. The list of JAR files used by Eclipse is displayed. Select "Add JAR" and select the Python Ant JAR file from the lib directory of the Eclipse Ant plug-in. Then, you can Add the Python Ant JAR file you just copied to the library list.

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.