Combining colon statements on one line?

Steven Bethard steven.bethard at gmail.com
Fri Jul 16 13:03:15 EDT 2004


Dave Blackington <metapsyc at yahoo.com> wrote in message news:<mailman.473.1089954583.5135.python-list at python.org>...
> '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.

Steve



More information about the Python-list mailing list