Pycharm - Improving and Writing Code


PyCharm includes various standards for writing code with proper indentations valid for Python. This makes it interesting to improve the code standards and writing the complete code in PyCharm editor.

Improving Code Completion

Code completion in PyCharm is really unique. You can enhance it further using many other features. Note that the editor provides start and end of the code block. Consider a file named with the following code −

message = 'GIEWIVrGMTLIVrHIQS' #encrypted message

for key in range(len(LETTERS)):
   translated = ''
   for symbol in message:
      if symbol in LETTERS:
         num = LETTERS.find(symbol)
         num = num - key
         if num < 0:
            num = num + len(LETTERS)
         translated = translated + LETTERS[num]
         translated = translated + symbol
   print('Hacking key #%s: %s' % (key, translated))

The code is completed using the following construct −

Complete Code

If you press Ctrl + spacebar while this popup is on the screen, you can see more code completion options −

Spacebar Option

Intention Actions

PyCharm includes intent specific actions and the shortcut key for the same is Alt+Enter. The most important example of intentions at work is using language injection in strings.

The screenshot given below shows the working of intention actions −

Intention Actions

Note that we can insert many different languages of intention actions in PyCharm Editor.