[Python-ideas] Syntax for easy binding __name__, __module__, __qualname__ to arbitrary objects

Jim Jewett jimjjewett at gmail.com
Mon May 13 17:49:11 CEST 2013


On Sun, May 12, 2013 at 9:33 PM, Raymond Hettinger
<raymond.hettinger at gmail.com> wrote:

> On May 9, 2013, at 3:29 AM, Piotr Duda <duda.piotr at gmail.com> wrote:

>> Animals = Enum('Animals', 'dog cat bird')
>> which violates DRY

> This is a profound misreading of DRY which is all about not repeating
> big chunks of algorithmic logic.

DRY, like most heuristics, is about making mistakes less likely.

Mistakes are likely with huge chunks of repeated logic, because people
are inclined to fix things at only one location.

Mistakes are likely with the above because it is conceptually only one
location, but syntactically two -- and doing something different in
the second location is a mistake that the compiler won't catch.

The problem with

>> Animals = Enum('Animals', 'dog cat bird')

is that you might accidentally type

>> Animals = Enum('Animal', 'dog cat bird')
or
>> Anmals = Enum('Animals', 'dog cat bird')

instead.

-jJ


More information about the Python-ideas mailing list