[Python-il] [pyweb-il:1072] Python coding question
szabgab at gmail.com
Fri Jul 9 08:22:46 IDT 2010
On Thu, Jul 8, 2010 at 3:18 AM, Rani Hod <rani.hod at gmail.com> wrote:
>> I wouldn't like the trade-off where you "win" a couple of
>> questions on mailing-lists and pay for it with the DRY in
>> complex_or_just_long_reference = complex_or_just_long_reference + 1
> But wouldn't you prefer something like
> complex_or_just_long_reference = same + 1
> which turns out to be more powerful than the standard pack of syntactic
> sugar constructs:
> complex_or_just_long_reference = max(same, new_thing)
> complex_or_just_long_reference = "(" + same + ")"
> IMHO, this is more readable and saves most of the mess with long names.
It took me a while to understand that same is a keyword here.
complex_or_just_long_reference = complex_or_just_long_reference.max(new_thing)
or, the same way as you do it for + writing something like this:
complex_or_just_long_reference .= max(new_thing)
More information about the Python-il