How call method from a method in same class?
Dan Sommers
2QdxY4RzWzUUiLuE at potatochowder.com
Mon Apr 1 22:15:44 EDT 2019
On 4/1/19 10:02 PM, Dave wrote:
> def validScale(self, scaleName):
> if scaleName.upper == 'F' or 'C' or 'K':
> return True
> else:
> return False
>
> def convertTemp(self):
> """ Converts temperature scale if scales valid."""
> if validScale(self.scale):
> scaleValid = True
> if validScale(self.newScale):
> newScaleValid = True
> if scaleValid and newScaleValid:
> print('Scale converted')
> else:
> msg = "There was and error with the scales entered.\n"
> msg = msg + "You entered: " + self.scale
> msg = msg + ' ' 'and' + self.newScale
> print(msg)
Note that validscale has a self parameter. Call it just
like you would from outside the class:
if self.validScale(self.newScale):
newScaleValid = True
More information about the Python-list
mailing list