4 ms·
A better title would be 'Useful Python Decorators by a Data Scientist'. Those decorators are exactly what data scientists would do, while software engineers wo
by TheAlchemist 4y ago
A better title would be 'Useful Python Decorators by a Data Scientist'.
Those decorators are exactly what data scientists would do, while software engineers would be terrified.
- rmbyrro 4y ago> while software engineers would be terrified At least surprised. There are solutions to these problems already. Author seemed to have learned decorators and is enthusiastic about abusing them, instead of learning the stdlib. The capturing of print statements. Why not use the Logging machinery, instead? Or the @stacktrace, it seems what they really want/need is a debugger. But anyway, if these solutions fit their programming style better, so be it.
- agumonkey 4y agoTo be fair, logging is badly made. There are at least two libs to make it human again.
- rmbyrro 4y agoIndeed fair. But even if I preferred the decorator style, I'd be cautious about dropping a stdlib or any other mature solution. When I create my own solutions, I tend to underestimate how hard it will be to get it working bug-free and to maintain it.
- anu7df 4y agoWhich ones do you suggest/recommend?
- imcoconut 4y agoim a big fan of loguru.
- mattkrause 4y ago@redirect could be handy when the print statements are embedded in someone else's code. We use a library that is very...chatty (some function calls send a screenful of info/progress to the screen), and I think I'm going to steal this to make it quieter.
- ramblerman 4y agoI found them quite creative tbh. Bad software engineers also tend to hide behind their best practices. It would be more interesting to point out the parts you feel are so terrible. Not everything has to be designed for a super critical prod environment with >10 coders working non stop on it.
- dragonwriter 4y ago> Not everything has to be designed for a super critical prod environment with >10 coders working non stop on it. And even when it does, cargo-culting rules-of-thumb is generally the wrong way to do that. Best practices are better treated as the Pirate Code than the Divine Writ.
- gjulianm 4y ago> Not everything has to be designed for a super critical prod environment with >10 coders working non stop on it. You don't need a super critical prod environment to have decent code. Half of these are hardcoding environment configuration, others have hidden side effects that the caller of the function cannot control at all, and others are badly reimplementing things that already exist (@redirect -> you want logging for this, @stacktrace -> use a debugger)
- mrtranscendence 4y agoA debugger isn't necessarily available in all environments. At my employer data scientists do a significant amount of their work in Databricks, where as far as I know it's impossible to drop into a debugger to trace execution. That said, I'm not really defending these specific decorators.
- inkeddeveloper 4y agoWell, there’s your first thing to fix.
- joshuamorton 4y ago
- apohn 4y ago>Those decorators are exactly what data scientists would do, while software engineers would be terrified. Actually, when I read the post I'd guessed this is what an ex Software Engineer who is now a Data Scientist would do. And looking at the author's LinkedIn confirmed it. You have to have a software engineering background to come up with this stuff in the first place.
- deleted 4y ago[deleted]