A critic of Guido's blog on Python's lambda

Tomasz Zielonka tomasz.zielonka at gmail.com
Sun May 7 02:17:14 EDT 2006


Alex Martelli wrote:
> Tomasz Zielonka <tomasz.zielonka at gmail.com> wrote:
>
>> Alex Martelli wrote:
>> > Having to give functions a name places no "ceiling on expressiveness",
>> > any more than, say, having to give _macros_ a name.
>> 
>> And what about having to give numbers a name?
>
> Excellent style, in most cases; I believe most sensible coding guides
> recommend it for most numbers -- cfr
><http://en.wikipedia.org/wiki/Magic_number_(programming)> , section
> "magic numbers in code".

I was a bit unclear. I didn't mean constants (I agree with you on
magic numbers), but results of computations, for example

    (x * 2) + (y * 3)

Here (x * 2), (y * 3) and (x * 2) + 3 are anonymous numbers ;-)

Would you like if you were forced to write it this way:

    a = x * 2
    b = y * 3
    c = a * b

?

Thanks for your answers to my questions.

Best regards
Tomasz



More information about the Python-list mailing list