我有4个变量,其中一些是真的和假的,对于每个组合,我必须调用一个或几个函数。
我目前正在为每种情况使用if-else语句,我想知道是否有更好的方法使用字典或其他工具来获得相同的结果。在
谢谢你
这是我的代码:if (self.cpe_ip and self.cpe_passwd) and self.phone and self.pppoe:
print "launch ISP portal, modem and radius"
if self.isp() == "east":
self.launchbell()
else:
self.launchtelus()
print 'check modem...'
self.modemstatus()
radius = sgp_radius.Radius(self.pppoe)
print 'check radius logs...'
self.data = radius.sgp()
self.radius_save()
#exit(0)
elif (self.cpe_ip and self.cpe_passwd) and not self.phone and not self.pppoe:
print "launch modem test only"
self.modemstatus()
#exit(0)
elif not(self.cpe_ip and self.cpe_passwd) and self.phone and not self.pppoe:
#print "only Bell po