Re:Show HN: Python Tests That Write Themselves
by timothycrosley on Wednesday September 18, 2019 @01:39PM
(#21007859)
While I agree, that `_param` generally means private, it is also a common way to allow parameters to be passed into a function where all other parameters are passed directly along via args and *kwargs to avoid naming collisions. An example of this is NamedTuple: https://docs.python.org/3/library/collections.html#namedtupl....
Re:Show HN: Python Tests That Write Themselves
by duckerude on Wednesday September 18, 2019 @02:42PM
(#21008571)
I believe Raymond Hettinger now considers that a mistake, and wishes he had gone with a trailing underscore (param_) instead. A trailing underscore is just as unlikely to lead to a collision, but less confusing.
Re:Show HN: Python Tests That Write Themselves
by timothycrosley on Wednesday September 18, 2019 @02:55PM
(#21008705)
That's a great call! I'll update this to use trailing underscore in a later version
Re:Show HN: Python Tests That Write Themselves
by timothycrosley on Thursday September 19, 2019 @02:04AM
(#21013715)
Updated in latest release to use trailing underscore: https://timothycrosley.github.io/hypothesis-auto/CHANGELOG/ figured it would be the least painful the earlier I did it :)
Re:Show HN: Python Tests That Write Themselves
by duckerude on Thursday September 19, 2019 @02:16AM
(#21013759)
Great!
It takes a bit of manual juggling, but if you take kwargs anyway you could inspect them to check for the old-style parameters, and use them if they're present, perhaps with a warning. That way you don't have to break compatibility.
This is especially true if the usecase is common enough to put in the top level examples