I have this
bc = \'off\'
if c.page == \'blog\':
bc = \'on\'
print(bc)
Is there a more pythonic (and/or shorter) way of writing this in Pyth
Another possibility is to use a dict if you can compute the values outside of the function that accesses them (i.e. the values are static, which also addresses the evaluation issue in scrible's answer's comments).
want_bc = {True: "on", False: "off"}
# ...
bc = want_bc[c.page == "blog"]
I prefer this and/or the tuple indexing solutions under the general rubric of preferring computation to testing.