0

I was going through part of a multi line comment as shown below:

def __init__(self):
    """
    Connect to Nexus 7
    RFCOMM port: 4
    Nexus 7 MAC address: 08:60:6E:A5:82:C8
    """

If I am not mistaken this is a multi line comment but for some reason Python uses the multi-line comment to establish the connection. Which makes me curious was to why it happens?

windboy
  • 141
  • 1
  • 9
  • 3
    "Python uses the multi-line comment to establish the connection.". Can you please expand on what you mean exactly by that? – idjaw Sep 30 '15 at 02:32
  • possible duplicate of [Multiline comments in Python](http://stackoverflow.com/questions/7696924/multiline-comments-in-python) – Remi Guan Sep 30 '15 at 02:33
  • 2
    Looks like a [docstring](http://epydoc.sourceforge.net/docstrings.html) to me – NightShadeQueen Sep 30 '15 at 02:35
  • I think the full source code is [here](https://github.com/rohitsm/ntu.sce.mdp.2/blob/master/bt_comm.py), I don't think the code uses the docstring to establish the connection. – Marius Sep 30 '15 at 02:36
  • From the code that marius show, how does python know how to find the bluetooth mac address, From the whole file i cannot find any method to establish the bluetooth connection. I tried running the python class file it accepts input from my bluetooth device when I changed the Nexus 7 MAC address: 08:60:6E:A5:82:C8 to the address of my device. which really puzzles me. – windboy Sep 30 '15 at 03:01

1 Answers1

0

You're right, it's a comment. Specifically it's a docstring as noted by @NightShadeQueen.

Docstrings for functions/etc. are also used to provide contextual hints in IDEs, like in Visual Studio Intellisense.

Comments like this do not provide any functionality or DO anything, they are just helpful for programmers using or reading the code at a later date.

Vikram Saran
  • 1,143
  • 8
  • 17