Right, I wondered why. I also found this code in layout to be a 'challenge':
middle_columns = {0:'span12',1:'span9',2:'span6'}[ (left_sidebar_enabled and 1 or 0)+(right_sidebar_enabled and 1 or 0)] }} It took me a while to figure out what was going on there -- it seems very clever and concise, but perhaps not the most readable code! (for me at least). On Tuesday, July 24, 2012 11:07:34 PM UTC+1, Jonathan Lundell wrote: > > On 24 Jul 2012, at 2:57 PM, villas wrote: > > But why not this which seems much more readble? > > value = +1 if mode == 'plus' else -1 > > > Originally for compatibility with Python 2.4. Not sure how much of a > priority that is these days... > > > > > On Tuesday, July 24, 2012 10:20:51 PM UTC+1, pjryan126 wrote: >> >> I'm working through this same example, and I'm having trouble >> understanding how the following resolves: >> >> value = (mode=='plus') and +1 or -1 >> >> Can anyone explain to me what is happening with this line of code? >> >> >> On Monday, March 26, 2012 10:28:27 AM UTC-4, Omi Chiba wrote: >>> >>> OK it worked ! >>> >>> The indent for last three line was wrong on book and it was fixed on the >>> downloaded code. >>> >>> >>> >>> On Friday, March 23, 2012 6:18:36 PM UTC-5, Omi Chiba wrote: >>>> >>>> Alan, >>>> >>>> Thanks. Good idea. I will try the support files. >>>> >>>> >>>> Sent from my Verizon Wireless BlackBerry >>>> >>> > > > --