On Fri, 11 Jan 2008 18:11:41 -0500 "Faber J. Fedor" <[EMAIL PROTECTED]> wrote:
> On 10/01/08 22:53 -0500, Mike Meyer wrote: > > Personally, I think it would be more pythonic to not try and use two > > different APIs to walk the list of jobs (... One Way To Do it): > > > > def __call__(self, where=None): > > q = "select * from %s" % (self.name,) + ("" if not where else (" where > > %s" % where)) > > Does this '("" if not where...' syntax actually work? I couldn't get it to > compile and I couldn't find any examples of such syntax (but you can't > expect googling for 'if not' to be too successful). Yes. >>> def test(name, where): ... return "select * from %s" % (name,) + ("" if not where else (" where %s" % where)) ... >>> test('mine', 'x = 3') 'select * from mine where x = 3' >>> test('mine', None) 'select * from mine' >>> test('yours', 'barfle is not NULL') 'select * from yours where barfle is not NULL' It is a 2.5 feature, though. I converted all my clients to 2.5.1, shortly after it was available, and haven't used anything older since. Sorry 'bout that. <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list