[Tutor] improvement of if - else code
Norman Khine
norman at khine.net
Thu Jun 4 19:25:20 CEST 2009
Hello,
Is there a better way to write this:
@staticmethod
def get_form(address=None, postcode=None, town=None, phone=None, fax=None,
freephone=None, address_country=None, address_region=None,
address_county=None, hotel=None):
context = get_context()
root = context.root
# List authorized countries
if hotel is True:
countries = [
{'name': y, 'title': x, 'selected': y == address_country}
for x, y in root.get_active_countries(context) ]
else:
countries = [
{'name': y, 'title': x, 'selected': y == address_country}
for x, y in root.get_authorized_countries(context) ]
Thanks
More information about the Tutor
mailing list