Python is readable

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Mar 16 00:58:08 CET 2012


On 15/03/2012 23:46, Kiuhnm wrote:
> On 3/16/2012 0:00, Arnaud Delobelle wrote:
>> On 15 March 2012 22:35, Ben Finney<ben+python at benfinney.id.au> wrote:
>>> Kiuhnm<kiuhnm03.4t.yahoo.it> writes:
>>>
>>>> Moreover, I think that
>>>> if (............
>>>> ............
>>>> ............):
>>>> ............
>>>> ............
>>>> ............
>>>> is not very readable anyway.
>>>
>>> I agree, and am glad PEP 8 has been updated to recommend an extra level
>>> of indentation for continuation, to distinguish from the new block that
>>> follows<URL:http://www.python.org/dev/peps/pep-0008/#indentation>.
>>
>> Personally I solve this by never writing if conditions that span more
>> than one line. If the worst comes to the worst, I would write:
>>
>> aptly_named_condition = (
>> very long condition
>> that goes over
>> plenty of lines
>> )
>> if aptly_named_condition:
>> do stuff
>
> Will I be able to use extra indentation in Python code?
> For instance,
>
> res = and(or(cond1,
> cond2),
> cond3,
> or(and(cond4,
> cond5,
> cond6),
> and(cond7,
> cond8)))
>
> I like it because it reads like a tree.
>
> Kiuhnm

Why not find out for yourself by slapping the code into an interactive 
Python interpreter and seeing what the result is?

-- 
Cheers.

Mark Lawrence.




More information about the Python-list mailing list