PyCharm Edu: Tips & Tricks for Most Efficient Learning, Part II
September feels just right to start learning, or continue with even more effort and joy. And today feels just right for the next post in our series covering learning methods and tips & tricks designed to help you to learn more effectively and make you more excited about learning Python with PyCharm Edu!
Last time we posted about how to make your IDE suit your needs and preferences, and help you stay focused and avoid distraction. Today we’re going to focus more on the process of writing code.
Learn faster with a smart code editor
As you learn to code, it is encouraging to have an intelligent assistant right inside your IDE. Language-specific syntax & error highlighting are there to help you avoid code mistakes. You can use code formatting capabilities to learn how to style your code. And you won’t get stuck with your Python coding with code completion and quick documentation at hand.
Use code completion
Learn with documentation
Explore the code
Fix code errors
Style your code
Please note that we use the default Mac OS keyboard shortcut scheme (Mac OS X 10.5+) in this blog post. For more about keyboard shortcuts, please see the previous blog post in this series.
Use code completion
Smart autocompletion is an essential feature of a professional code editor, which helps you save time and avoid misprints. It is equally powerful for learning because you can use it to find the right variable, function, parameter, or any code construct. Start typing or simply press Control-Space to get a list of suggested options:
Code snippets, or live templates, can also be a handy tool. They not only speed up your coding, but help you learn new language syntax as well. Use Command-J to see the full list of code snippets available. Start typing to find the one you want to add, and then use Tab to fill in the blanks:
Learn with documentation
Reading documentation is a must when learning a new programming language. PyCharm Edu makes this process as seamless as possible.
Put a cursor on a class, method, variable, or function you want to read about, and then press F1 to open the quick documentation pop-up:
Use F1 once more to switch to the tool window mode:
You can click hyperlinks to find more details. For example, click int to read about the int class:
Use the Back and Forward icons to get back to the documentation pages you visited recently:
Save your time and effort with the special Auto-update from Source icon. When switched on, it lets you read the documentation in parallel with reading your code. Go through a code fragment and read about all the code constructions you put your cursor on, without any additional shortcuts or mouse clicks:
Explore the code
Programming is much more about understanding and reading existing code than about writing new code. That’s why we develop so many code navigation features in our IDEs. While learning, it is also quite important to see your code as a whole and understand how it works.
When you use any variable, function, or method and need a tip on how it works, let the code speak for itself. Press Command-B to go to the declaration of an entity; use it one more time on the declaration to see the list of usages:
Another quick way to look at the declaration is to use the pop-up (with Command-Y):
Fix code errors
Mistakes are an essential part of successful learning. They can also be very annoying and drain your motivation. The IDE helps you not get stuck in code errors, by alerting you to the most common ones and suggesting solutions.
Take a look at the code below. The red squiggly line code under task means there’s something wrong with this statement:
Put the cursor on the highlighted code to see what the issue is. Then, click the red bulb or press Option-Enter to see the list of suggested fixes. Choose the right one to fix your code:
It seems there is still something wrong with the file, because there’s a red icon at the top right:
Click the red stripe to navigate to the line with the error and fix it:
Now everything is fixed:
Style your code
It is important not only to write the right code, but also to write your code right. Try to follow a code style so your code is easy to read and understand. You’ll thank yourself later!
Invoke Option-Command-L and let the IDE reformat your code automatically:
There we have it. Let us know how you like these features! Stay tuned for the next portion of tips & tricks for more efficient learning. Share your feedback here in the comments or report your findings on YouTrack, to help us improve PyCharm Edu.
—
Your PyCharm Edu Team