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.
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
Subscribe to Blog updates
Thanks, we've got you!
Five Things To Love About the New UI
Are you using the New UI yet? Not yet? Let me tell you why it's the best thing since sliced bread! Let’s get it enabled and take a look around. The easiest way to do that is from the Settings cog at the top-right of the UI: PyCharm will need to restart, but that’s it; you’re done! In t…
Tutorial: Visual testing with pytest
If you are like many Python developers out there you LOVE writing code! Tests? Not so much. Whether it’s the concept of testing or the interface of testing tools, testing is a chasm not all developers cross. The Visual Testing with pytest tutorial aims to bring Python testing to the masses, tak…
Django Custom Tags in PyCharm Professional 2020.1
PyCharm started its life with Django support and our new release adds some useful improvements for Django coding. Let's take a look at support for custom Django tags in PyCharm Professional 2020.1. But First, One More Thing Maybe it's bragging, but we need to show one existing feature related to thi…
Python 3.8 support in PyCharm
The release of Python 3.8 brought new features to the Python coding realm. The language is evolving according to its community's needs by addressing cases where new syntax or logic become necessary. From new ways of assigning expressions to restriction of usage of function declarations, calls, and v…