[Freeipa-devel] [PATCH] 035 Fixes for the DNS plugin

Jakub Hrozek jhrozek at redhat.com
Fri Jan 7 16:59:19 UTC 2011


On 01/07/2011 05:28 PM, Adam Young wrote:
> I'm Not a pythonista. What is this line doing?
>
>
> On 01/07/2011 10:58 AM, Jakub Hrozek wrote:
>> + nameserver = nameserver[-1] == '.' and nameserver or nameserver + '.'
>

This construct is called the 'and-or trick' and somewhat resembles 
ternary operator (which was added to python in 2.7 IIRC, so I'm not sure 
if it's old enough to use) from C and other languages. See 
http://diveintopython.org/power_of_introspection/and_or.html#d0e9975 for 
details.

But yeah, a simple if would be more readable. A new patch is attached, 
thanks for bringing it up.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jhrozek-freeipa-035-02-dnszone-fix.patch
Type: text/x-patch
Size: 1500 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20110107/45484a91/attachment.bin>


More information about the Freeipa-devel mailing list