2 ms·
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 pa
by timothycrosley 7y ago
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#namedtuple-factory-function-for-tuples-with-named-fields https://docs.python.org/3/library/collections.html#namedtupl....
- duckerude 7y agoI 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.
- timothycrosley 7y agoThat's a great call! I'll update this to use trailing underscore in a later version
- Izkata 7y agoPersonally, I like how django does it, where one of the kwargs accepts a dict, and that dict is what's passed along as kwargs to the next level.
- timothycrosley 7y agoUpdated in latest release to use trailing underscore: https://timothycrosley.github.io/hypothesis-auto/CHANGELOG/ https://timothycrosley.github.io/hypothesis-auto/CHANGELOG/ figured it would be the least painful the earlier I did it :)
- duckerude 7y agoGreat! 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.