1

Can we get bold comments in Python/Spyder IDE? In MATLAB, a comment started with % symbol will be in normal text and a comment starting with %% will be shown in bold. Is there an equivalent symbol for Python Spyder IDE?

Python comments

MATLAB comments

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
user408108
  • 135
  • 11
  • not bold per-say, but here's a list of what is highlighted by the outline explorer: https://stackoverflow.com/a/57569961/3220135 you can also separate your code into "cells" like ipython notebooks with `#%%` – Aaron Jan 24 '21 at 06:10
  • 1
    Several specific comments can also be identified via the "todo list" feature, which get marked in the gutter / scrollbar similar to how errors get marked: `#TODO`, `# FIXME` `# XXX`, `# HINT`, `# TIP`, `# @todo`, `# HACK`, `# BUG`, `# OPTIMIZE`, `# !!!`, and `# ???` – Aaron Jan 24 '21 at 06:16

2 Answers2

1

In Matlab, %% not only makes the following text bold but also creates a section. In Spyder IDE you can create a section using #%%, but it will not show the specific comment in bold.

However, if you wish to display all comments as bold, you can achieve it through Preferences > Appearance > Color scheme editor > Comment > "Check Bold". Through the Color scheme editor you can also change the color and italics option.

enter image description here

pkj
  • 559
  • 1
  • 9
  • 21
0

While triple quotes are typically used for multi-line comments in Python, in the IDE I use (PyCharm), they show up in bold type.

''' Write your Python comment here. '''
""" Write your Python comment here. '''

In Spyder, I think these same comments would be italicized.

Gitanjali
  • 127
  • 3
  • 9
  • 1
    Triple quotes is actually a multi-line *string*, it's just that you can have a string literal which isn't assigned to a variable. It should also be noted that the first such string (triple quoted string not assigned to any variable) gets saved as the "docstring" for the nearest scope (function, class, module), and is the string returned by the `help` function. see: https://www.python.org/dev/peps/pep-0257/#what-is-a-docstring – Aaron Jan 24 '21 at 07:52
  • 1
    "In Spyder, I think these same comments would be italicized." they are not. They get styled with the same color / styling as regular strings (because they are regular strings that can just span multiple lines) – Aaron Jan 24 '21 at 07:56