Browse files

Use correct python convention for what's private and what is part of …

…the public api of the class, also python style method names
  • Loading branch information...
1 parent 5429543 commit 2d1de053becc31a860924c027887da501652a8e6 @emilybache emilybache committed Sep 20, 2012
View
2 TDDMicroExercises/python/TextConverter/unicode_to_html_converter.py
@@ -5,7 +5,7 @@ class UnicodeFileToHtmlTextConverter(object):
def __init__(self, full_filename_with_path):
self.full_filename_with_path = full_filename_with_path
- def convertToHtml(self):
+ def convert_to_html(self):
f = open(self.full_filename_with_path, "r")
html = ""
for line in f:
View
21 TDDMicroExercises/python/TirePressureMonitoringSystem/tire_pressure_monitoring.py
@@ -18,17 +18,14 @@ def sample_pressure():
class Alarm(object):
def __init__(self):
- self.low_pressure_threshold = 17
- self.high_pressure_threshold = 21
- self.sensor = Sensor()
- self.alarm_on = False
- self.alarm_count = 0
+ self._low_pressure_threshold = 17
+ self._high_pressure_threshold = 21
+ self._sensor = Sensor()
+ self.is_alarm_on = False
+ self._alarm_count = 0
def check(self):
- psi_pressure_value = self.sensor.pop_next_pressure_psi_value()
- if psi_pressure_value < self.low_pressure_threshold or self.high_pressure_threshold < psi_pressure_value:
- self.alarm_on = True
- self.alarm_count += 1
-
- def is_alarm_on(self):
- return self.alarm_on
+ psi_pressure_value = self._sensor.pop_next_pressure_psi_value()
+ if psi_pressure_value < self._low_pressure_threshold or self._high_pressure_threshold < psi_pressure_value:
+ self.is_alarm_on = True
+ self._alarm_count += 1

0 comments on commit 2d1de05

Please sign in to comment.