[Python-ideas] A more readable way to nest functions
Mikhail V
mikhailwas at gmail.com
Mon Jan 30 18:54:01 EST 2017
On 30 January 2017 at 21:25, David Mertz <mertz at gnosis.cx> wrote:
> On Mon, Jan 30, 2017 at 11:52 AM, Mikhail V <mikhailwas at gmail.com> wrote:
>
>> *Theoretically* I see a solution by 'inlined' statements.
>> Take a long example:
>>
>> print ( merge (a, b, merge ( long_variable2, long_variable2 ) )
>>
>> Now just split it in 2 lines:
>>
>> tmp <> merge ( long_variable2, long_variable2 )
>> print ( merge (a, b, tmp ) )
>>
>> So I'd for example invent a special sign which just marks
>> statements that will be first collected as inline text, sort of macros.
>>
>
> I have a great idea for this special sign. We could use the equal sign
> '=' for this purpose of assigning a value into a temporary name. :-)
>
> tmp = merge(long_variable2, long_variable2)
> print (merge(a, b, tmp) )
>
>
>
Great idea :) But actually that was my idea initially, so just breaking it
into two lines solves the readability issue perfectly with long
expressions. Although if one is chasing some kind of optimisations... I
don't know, I see very often people want to stick everything in one big
expression.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170131/dea5c1d4/attachment.html>
More information about the Python-ideas
mailing list