[Python-Dev] How far to go with user-friendliness

Berker Peksağ berker.peksag at gmail.com
Tue Jul 14 17:06:32 CEST 2015


On Tue, Jul 14, 2015 at 5:00 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Tue, Jul 14, 2015 at 11:09:50PM +1000, Nick Coghlan wrote:
>
>> Dima's right that the main defence against this kind of error is
>> actually linters and IDEs, but detecting this particular one at
>> runtime is harmless, so there's no particular reason *not* to do it
>> when it's possible to construct a reasonable rationale for "Why this
>> particular typo?" and not all the other possible ways of transposing
>> adjacent letters in "assert".
>
> I've read this thread and the bug report and I'm not sure about this
> reasonable rationale. It seems like an utterly arbitrary choice to
> single out a single typo for special treatment while ignoring other
> equivalent typos, equally easy to make and equally difficult to spot.
> You even mentioned people with dyslexia yourself. As I understand it,
> dyslexics would find assert and assery equally hard to distinguish as
> assret versus assert, and t and y are next to each other on the same row
> of QWERTY keyboards.
>
> BTW, am I missing something? The issue tracker says that the patch was
> accepted and a new "unsafe" keyword argument was added over a year ago,
> but that doesn't seem to be documented anywhere here:
>
> https://docs.python.org/3/library/unittest.mock.html

It's new in Python 3.5:
https://docs.python.org/3.5/library/unittest.mock.html#unittest.mock.Mock

"unsafe: By default if any attribute starts with assert or assret will
raise an AttributeError. Passing unsafe=True will allow access to
these attributes."

--Berker


More information about the Python-Dev mailing list