I think there must be a more pythonic way to achieve the lowercase-forcing that I need to do here. The keys in my lookup (self.adjustments) are all lc, params sent in to function can be any case (data coming from third party). Also, is it objectionable to have self.adjustments
used here but not passed in?
def getRevenue(self, metric, productParam, platformParam):
product = productParam.lower() # better way to do this?
platform = platformParam.lower() # better way to do this?
# get adjustment for product.platform, multiply by metric
if product not in self.adjustments:
raise Exception('Unknown adsense product: {}'.format(product))
[productParam, platformParam].each{|e|e.downcase!}
- see grab.by/FmQM \$\endgroup\$ – Devon Parsons Mar 6 '15 at 16:45