The most comprehensive Pycharm tutorial (29)-exploring IDE and quick reference

Source: Internet
Author: User
Tags web2py

The most comprehensive Pycharm tutorial (29)-exploring IDE and quick reference

1. Preparations

(1) Confirm that the Python interpreter is installed. versions 2.4 to 3.4 are acceptable.

(2) Note that Pycharm has two released versions: Community Edition and Professional Edition. For details, see section Comparison Matrix.

2. initialize Installation

When installing Pycharm for the first time, the installer will ask you several important questions:

(1) Whether the configuration information has been saved in advance (for example, the configuration information of earlier versions)

(2) license information

(3) shortcut key configuration and background topic

Note that Pycharm has preset several shortcut keys, such as Eclipse or Visual Studio, and GNOME and KDE tailored to Emacs fans. For more information, see the shortcut key solution list on the Keymap page in the Settings dialog box.

For Vim professionals, we recommend that you use the IdeaVim plugin plug-in for PyCharm. Python also provides external plug-ins for those users who are used to Emacs development.Use it as an external editor.

Of course, we can change the initial settings later. For more information, see documentation and the following two Tutorials:

  • Getting started with PyCharm
  • Refreshing ing keyboard schemes

    3. Welcome Page settings

    If you use Pycharm for the first time (you have not created a project), you will first enter the Welcome screen. Click Configure. Pycharm will prompt you to verify the current environment, plug-ins, import and export, and other related external configurations. Click Configure again to go to the Settings/Preferences dialog configuration dialog box. Note that the dialog box title is "Default Project" by Default ":

    This means that the above configuration is used by default every time you create a new project. If you want all newly created projects to use the same interpreter, you can set define such an interpreter in Default Project settings:

    The default editing environment can also be set here. For example, if you want to keep displaying the row number of the code, you need to expand the Editor node in the Setting Dialog Box. On the Appearance page, select the check box corresponding to "Show line numbers:

    Next let's assume that you want to use a specific color topic. OK, select the basic topic, copy it, and change the color scheme (the color subject preset by the system cannot be changed ).

    Of course, the font size can also be changed. These operations must be performed on the Colors and Fonts settings page. Similarly, you need to create a topic backup to define the font size of the editor. These settings apply to the font of the editor, but do not change the font of other control areas.

    You can preview the changed effect in the preview window:

    For more details about the appearance theme settings, see What my PyCharm looks like.

    Of course, after a project is created, we can change it at any time, which will be discussed in the following chapter What my PyCharm looks like.

    Finally, you can choose to hide or display some controls on the user interface: toolbar buttons, menu bar buttons, and main toolbar buttons. Pycharm also allows you to select the view mode. For details, see:

    • PyCharm tool windows
    • Presentation and Full Screen viewing modes

      4. Engineering

      Any operations you perform in Pycharm should belong to a project. The most interesting thing is Pycharm's project manager, which allows us to open multiple projects in one frame under one frame. When you create a New Project (File> New Project) or Open an existing Project (File> Open), Pycharm will ask you how to Open it: in a new window, add it to the current window.

      You can open multiple projects in a window as needed. In this case, the first project is considered as the main project, and the symbols of other projects are available in the main project.

      Create a new project as an exercise and enter some code. For more information, see Getting started with PyCharm. For more information, see Creating a simple project.

      5. Engineering type

      Pycharm provides various engineering types: Django, Flask, Pyramid, and web2py. When creating a project, select the corresponding project type in the list as needed.

      It can be seen that Pycahrm supports all mainstream Python frameworks and will help generate the corresponding file structure and necessary components. For details, see:

      • Django
      • Flask
      • Pyramid
      • Google App Engine
      • Web2Py

        6. Start

        At this time, the project has been created. Press the Shift key twice before starting the work. A window will pop up for us to find and jump:

        As you can see, you can search for any information about Pycharm, commands, settings, file information, controls, and so on. This is only part of the Pycharm search navigation function.

        7. Private engineering Customization

        Click the Settings button on the main toolbar to go To the Settings dialog box. The Settings/Preferences dialog box allows you to change the project structure, install controls, and adjust the development environment.

        Some settings are mainly for specific projects, such as the project interpreter type, configuration attributes, and file color. Others, such as the edit box setting, shortcut keys, and template generation, are for the overall development environment and do not need to depend on a specific project.

        8. Engineering Interpreter

        Required for Python interpreter. If the interpreter configuration is invalid, Pycharm will give the following error message:

        In Pycharm, you can define several interpreters at the same time, and then select one to apply to the project.

        In short, you must clearly tell Pycharm which interpreter to use to facilitate its use of a different interpreter for each project:

        Pycharm interpreter types include:

        • Local
        • Remote
        • Virtual environments

          9. Local Interpreter

          Download the Python interpreter, install it locally, and execute the interpreter ......, For details, see tutorial or product documentation.

          10. Remote Interpreter

          Pycharm allows the use of remote interpreters, such as through reliable servers. Previously, Pycharm had to use SSH connection or Vagrant box for remote interpreter configuration. For details, see sorting interpreters with PyCharm.

            11. Virtual Environment

          Importance? Suppose you are writing a project using Django 1.6, and you need to support another project that requires using Django 1.2. At this time, you need some means to ensure the security and consistency of your operating environment, that is, a tool is used to create a copy of the Python compiler. For details about how to create a virtual environment, see documentation and tutorial.

          12. Third-party libraries and their paths

          For example, the version of the interpreter, Pycharm can help us install and update some necessary third-party libraries. For example, if Pycharm detects some missing or third-party libraries to be updated, it will prompt us to install and update them:

          The same applies to path updates. If the library is installed or updated, we recommend that you scan the Python installation directory again. Click the button and select more. In the project interpreter Settings dialog box, select the interpreter to be viewed and click the button. In the interpreter path dialog box, click the button to update the database.

          For more information, see product documentation.

          13. VCS (Version Control System)

          Pycharm helps us implement Version Control for existing projects.

          Of course we can fine-tune it. In the Settings/Preferences dialog box, click the Version Control node (Project Settings → Version Control). By default, only the root directory of the Project is displayed, however, you can divide your application into smaller blocks for management.

          In the Settings/Preferences dialog box, the changed command behavior will be applied to all Version Control Systems: Confirmation information for creating/deleting files, background control methods, and so on.

          For more information, see:

          • Version control basics
          • Using PyCharm's Git integration locally
          • Sharing via a remote repository

            You can also refer to the Pycharm documentation:

            • Version control with PyCharm
            • Version control procedures

              14. File color

              Your project may contain several projects, and the file names under each project directory may be the same (such as init. py, models. py, tests. py, views. when they are opened in the editor at the same time, to help distinguish the project to which they belong, pycahrm uses its label color to mark (Settings/Preferences → Project Settings → File Colors ). Try to split your project, and then work out their respective file color schemes.

              For more information, see sorting scopes and file colors.

              15. IDE and Editor

              IDE is responsible for improving the programming environment, optimizing the visual experience, and improving operation efficiency. Therefore, Pycharm allows you to customize your IDE and editor, such as shortcut keys, scroll bars, and highlight. For more information, see

              • Login ing project and IDE settings

                The preceding Settings are the Settings/Preferences dialog completed in the Settings dialog box. Click the Settings button on the main toolbar to go to the corresponding page and set it. We recommend that you adjust the settings on these pages: Appearance and Keymap.

                16. Appearance

                Choose Settings/Preferences> Appearance and Behavior> Appearance to customize the Appearance. Click the Look and feel drop-down list and select a favorite topic. Click the Apply button to preview the effect of the selected topic. You do not need to close the dialog box until you are satisfied.

                For more information, see How do I choose look and feel for my PyCharm? And product documentation.

                17. Editor

                All Editor Settings are under the Editor node (Settings/Preferences → Editor), including the color scheme, Font, and highlighted display mechanism. In addition, you can quickly preview the changes in the preview window.

                For more information, see How do I change color scheme of the editor and product documentation.

                18. Shortcut Keys

                The setting of the shortcut key depends on your operation habits.

                Use Settings/Preferences → Appearance and Behavior → Keymap to open the shortcut key setting window, select the corresponding shortcut key scheme, and set a specific shortcut key combination.

                There is a powerful shortcut Ctrl + Back Quote, which can switch between different topics without opening the Setting dialog box.

                For more information, see ing keyboard schemes and product documentation.

                19. External Editor

                Pycahrm can be converted to other editors by Using external plug-ins, such as Emacs. For details, see Using Emacs as an external editor.

                20. Background tasks

                Pycharm provides a progress bar for some time-consuming Tasks. We can hide it in the Background (still visible). For details, see Working with Background Tasks.

                21. Code intelligence

                Pycharm provides some convenient smart prompts during code writing, mainly reflected in:

                (1) Spelling prompt (Ctrl + Space) code completion

                (2) Use the generated template Creating and applying live templates (code snippets), product documentation

                (3) code Quick fixes and intention actions once more and product documentation

                22. Use of macros

                Using macros can simplify the editing process. For details, see Using macros and documentation.

                23. Multi-file Working Environment

                By default, Pycharm opens the file by editing the option card separately:

                We can manually switch the order of these tabs, fixed or unfixed, side display, split, and so on:

                For details, see section Managing editor tabs and tutorial.

                24. Show Code Analysis

                Pycharm provides various prompts to help you discover and correct errors in the code.

                First, when you enter the code, it will mark all syntax errors with red Tilde, and mark the corresponding row in the right slot to display the error information in the lower state, when you hover the mouse over the corresponding tag, a brief error message is displayed:

                Pycharm also displays red and yellow bulb icons on the left to indicate errors and warnings.

                The next step is static code analysis, that is, code check, and the corresponding mark is given in the right slot. Red indicates an error, yellow indicates a warning, and the top right corner indicates the overall error of the file. Green indicates that everything is normal, and red and yellow indicate an error.

                The Hector icon in the lower-right status bar is used to indicate the current error correction level.

                If you are confident in your programming skills, click it to close the code check.

                However, if you want to check the Code of the entire project to improve the Code quality, select Code> Inspect Code and display the Code check result in Inspection tool window:

                For more information, see Syntax highlighting and error indication.

                25. create high-quality code

                For details, see Code Quality Assurance Tips and Tricks. or How to make your code look pretty?

                26. View Document Information

                Pycharm has several ways to browse documents:

                • Quick definition
                • Quick documentation
                • External documentation
                • Parameter info
                • Error description

                  These methods correspond to direct menu commands and shortcut key settings:

                  For details, see Viewing documentation and Viewing reference information.

                  27. search and search

                  28. Source Code Search

                  The most basic search method is the Ctrl + F command:

                  Pycharm runs for a deeper look: a specific directory, any range, the entire project (Ctrl + Shift + F ):

                  Pycharm can also search for all the application environments of a symbol, press Alt + F7, or use the Find usages command in the shortcut menu:

                  There are other similar commands: Ctrl + F7 to achieve jump; Ctrl + Shift + F7 to browse Usages in the form of code coloring; Ctrl + Alt + F7 to search the entire project in the form of a pop-up window.

                  You can click the intermediate key or press Ctrl + B to jump to the corresponding declaration.

                  Ctrl + N: Quickly search for a class by name; Ctrl + Shift + N: Quickly search for a file by name; Ctrl + Shift + Alt + N; quickly search for a symbol by name, wildcard names can be used for these searches.

                  29. IDE control search

                  Here is a brief introduction. Take switcher as an example. Press Ctrl + Tab to display switcher. Press Ctrl not to place it, and use the Tab or direction key to scroll to the target position:

                    

                  If you Select an IDE component and want to browse it from other components, use Select Target (Alt + F1 ):

                  The Esc key is used to return to the edit box.

                  30. command search

                  You can search for invoke it by name using simple commands to find and use the corresponding commands (without the main menu ). Press Ctrl + Shift + A and enter the corresponding letter:

                  Note that you can search for commands not included in the main menu here, just press Ctrl + Shift + A again.

                  31. Search for any navigation location

                  Press Shift twice, or click the button on the right of the main toolbar to open the Search everywhere dialog box, where you can find anything.

                  For more information, see locking ing navigation and search, Navigating through the source, Searching through the source code.

                  32. refactoring code

                  We recommend that you refactor Pycharm based on the current Code environment.

                  33. Run, debug, and test programs

                  34. Run the code

                  Right-click the shortcut menu or press Ctrl + Shift + F10 to run the Code. If you want to use other configuration information to run the code, select it from the main menu bar and press Shift + F10.

                  For more information, see Code running maintenance and Running.

                  Pycharm allows remote debugging and running of virtual machine and Vagrant boxes.

                  35. REPL Console window

                  Under the Tools menu, select the command to load Python or Django console. The Pycahrm console can highlight code, spelling tips, and display History commands (Ctrl + Up/Down)

                  Pycharm can also run the code in the editor on the console. Select the code and press the Alt + Shift + I shortcut key (you can also use the command in the shortcut menu). For more information, see REPL-running an interactive console and Working with tables les.

                  36. Local Terminal

                  Select Tools> Open Terminal's main menu command to go to the command line operation mode:

                    

                  For more information, see product documentation.

                  37. debugging

                  The debugging method is very simple. Select the script to be debugged, specify the configuration file, and press Shift + F9.

                  Select the shortcut for running/debugging configuration file: Alt + Shift + F10/Alt + Shift + F9

                  For more information, see Debugger, Breakpoints, Debug run, and Debugging.

                  38. Test

                  Pycharm provides the following test methods:

                  (1) create a test class

                  (2) Specify the configuration file for testing

                  (3) run/debug the test class

                  (4) view results

                  Pycharm supports the following mainstream Python testing frameworks: Unittest, Doctest, Nosetest, py. test, and Attest. The related configuration files are preset.

                  For more information, see Creating and running a Python unit test, Unit tests, and Testing.

                  39. Remote Operation

                  First, upload the local script file to the remote Server. For more information, see running ing Synchronization with a Web Server.

                  Next, you can remotely debug and run related files. For more information, see compare local and remote folders, and synchronize local copy with that deployed on the server

                  40. Database and SQL support

                  Pycharm provides database support. Once you have obtained permissions for a database, you can use Pycharm to store more data sources in the same format with the existing License book. Pycharm helps with data connection.

                  For more information, see product documentation.

                  41. Support for Multiple Programming Languages

                  Pycharm supports Python, JavaScript, CoffeeScript, HTML, XML, and other programming languages. Its powerful code assistant can meet the needs of various programming languages.

                  Pycharm also supports JavaScript code Debugging. For details, see JavaScript-Specific Guidelines and Debugging JavaScript with PyCharm.

                  42. Success

                  This is Pycharm's commonly known manual. It briefly introduces its features to help you get started quickly.

                    

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.