MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / __str__

Method __str__

Software/Python/easysensors.py:171–195  ·  view source on GitHub ↗

Prints out a short summary of the class-instantiated object's attributes. :returns: A string with a short summary of the object's attributes. :rtype: str The returned string is made of the following components: * the :py:attr:`~easysensors.Sensor.desc

(self)

Source from the content-addressed store, hash-verified

169 pass
170
171 def __str__(self):
172 """
173 Prints out a short summary of the class-instantiated object's attributes.
174
175 :returns: A string with a short summary of the object's attributes.
176 :rtype: str
177
178 The returned string is made of the following components:
179
180 * the :py:attr:`~easysensors.Sensor.descriptor`'s description
181 * the :py:attr:`~easysensors.Sensor.port` name
182 * the :py:attr:`~easysensors.Sensor.pin` identifier
183 * the :py:attr:`~easysensors.Sensor.portID` - see :py:meth:`~easysensors.Sensor.set_port` method.
184
185 Sample of returned string as shown in a terminal:
186
187 .. code-block:: console
188
189 $ ultrasonic sensor on port AD1
190 $ pinmode OUTPUT
191 $ portID 3
192
193 """
194 return ("{} on port {} \npinmode {}\nportID {}".format(self.descriptor,
195 self.get_port(), self.get_pin_mode(), self.portID))
196
197 def set_pin(self, pin):
198 """

Callers

nothing calls this directly

Calls 2

get_portMethod · 0.95
get_pin_modeMethod · 0.95

Tested by

no test coverage detected