Introduction to Python Projects

Source: Internet
Author: User
Tags netbeans

The Python project is well known for its elegant design and rapid development efficiency, and has won the favor of many developers. Many built-in object details such as dictionaries and strings have undergone great changes, and some contents of the Standard Library have been reorganized.

The download package of NetBeans IDE 6.5 does not currently support Python, but NetBeans IDE also provides a Python Early Access version of only 28 m for Python programmers. When downloading and installing, the Early Access version will automatically find the installation location of the existing NetBeans, and integrate the Python language support in the existing NetBeans IDE during installation.

After you start NetBeans IDE, you can choose to create a new Python project in the new project or create a Python project based on existing code. Of course, Python EA can also be found in available plug-ins of NetBeans 6.5 and updated and installed online. Currently, the default Python parser in IDE is Jython 2.5 beta.

Developers can add other Python interpreters implemented in C language as needed. Python EA provides code editing features such as highlighting, code folding, and smart sensing for Python encoding. At the same time, IDE provides the Python Command Execution console, as well as code debuggers supporting Jython and CPython.

Python EA still has a small Bug on the Mac platform, but it can solve the problem according to the method given in the contact group. The NetBeans Wiki also shows how to use Python EA in version 6.5. Python support has been officially included in the release of NetBeans IDE.

Although file and directory processing can be completed by operating system commands, the Python language allows developers to process related work in a programming manner, provides many built-in functions for processing files and directories. Importantly, these functions are used in the same way on Unix, Windows, and Macintosh platforms.

This article will explain in detail how to use these functions. First, we will introduce the file listing function in Python, which is similar to the dir command in Windows, and then describe how to test whether a file name corresponds to a standard file, directory, or link, and how to extract the file size and date.

After that, we will also introduce how to delete files and directories, copy and delete files, and how to break a complete file path into a directory part and a file name part. Finally, we will explain how to create directories and how to move directories and process files in the directory tree.

We know that the file name, directory name, and link name all use a string as its identifier, but give us an identifier, how can we determine whether it refers to a regular file name, directory name, or link name? In this case, we can use the isfile function, isdir function, and islink function provided by the OS. path module to achieve our goal, as shown below:

It is actually too strict. All we need is a file/directory name sequence that is traversed. In fact, we do not care whether the name is stored in a list, tuples, or numeric array, so a better test should be like the following:

 
 
  1. Import shutil
  2. Shutil. copy (myfile, tmpfile)
  3. # Copy last access time and last modification time:
  4. Shutil. copy2 (myfile, tmpfile)
  5. # Copy a directory tree:
  6. Shutil. copytree (root_of_tree, destination_dir, True)

The Python project can well support the cross-platform structure of path names: OS. path. the correct delimiter (used in UNIX and Mac OS x operating systems, and in Windows) can be used to join directories and file names. The variable OS. curdir and OS. pardir indicates the current working directory and its parent directory respectively. Such as the following UNIX operating system commands.

  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.