News for hackers. Stuff that matters.
Re:Useful Python decorators for data scientists by saeranv on Monday May 23, 2022 @06:46AM (#31477352)
What other antipatterns are there? I can understand the criticism of having configuration code with business logic, and think there should be better commenting/docstrings.

But other then that, thought it was fine. The use of type hints is pretty awesome, in particular. Do you guys just not like higher-order functions?

Re:Useful Python decorators for data scientists by gjulianm on Monday May 23, 2022 @07:03AM (#31477471)
Type hints in that code are erasing the actual signature of the function, so you won't get type checks on the arguments. For @redirect, you'd be better served by using the logging module.

Higher order functions are ok, but the problem with this what they're using it for. Code that behaves different based on environment without any explicit warning for the caller? That's fairly dangerous.

Re:Useful Python decorators for data scientists by mrtranscendence on Monday May 23, 2022 @09:40AM (#31478901)
> Type hints in that code are erasing the actual signature of the function

True enough. For the reader of these comments, it's possible (but non-obvious) to properly respect type hints in a decorator. See here: https://mypy.readthedocs.io/en/stable/generics.html#declarin...