Combining colon statements on one line?

Steven Bethard steven.bethard at
Fri Jul 16 19:03:15 CEST 2004

Dave Blackington <metapsyc at> wrote in message news:<mailman.473.1089954583.5135.python-list at>...
> '972' '006'
> I have two dates without the millenium included. 
> Using basic 'if' 'else' communication, this, it seems
> to me would require 4 lines of python to add the
> correct millenium.

How about:

abbrYear < PIVOT_YEAR and 2000 or 1000

and's and or's will usually do the trick unless one of the result
values evaluates to false, e.g.

abbrYear < PIVOT_YEAR and 0 or 1000

would be bad because it would alway give you 1000.  But in your case,
I think yo're okay.


More information about the Python-list mailing list