4 ms·
> The process to "promote" fragments of a notebook into being reusable functions seemed very high-friction: basically you're rewriting it as a normal Python pac
by spywaregorilla 3y ago
> The process to "promote" fragments of a notebook into being reusable functions seemed very high-friction: basically you're rewriting it as a normal Python package and then adding that to Jupyter's environment.
Don't get in that situation to begin with. Pop an `%load_ext` `%autoreload 2` at the top and just write functions in an imported .py file from the get go.
- jey 3y agoOk, but let's also acknowledge that the mental model and levels of abstraction increased significantly, which presents a barrier to people without any prior software engineering experience, who are just getting into Python for "data science".
- mstipetic 3y agoWell maybe we should expect people to learn the tools they use properly instead of constantly dumbing things down for the sake of convenience. I’m not sure you should be able to just pop in and do “data science”
- spywaregorilla 3y agoI don't think it's a huge leap to say your functions are stored in this .py file vs. in a cell above. the magic commands simply allow you to reload the functions automatically without needing to reimport / reload the kernel.
- fluidcruft 3y agoIt is a huge gap when the notebook is documentation. Moving functions out either duplicates documentation or separates them. Notebooks are vastly superior for documentation. Extracting functions from notebooks into a py file isn't difficult (see nbdev for example)
- spywaregorilla 3y agoNotebooks are good for demonstration, not documentation. They are bad for documentation because you need to put docstrings and comments in the code while desiring to put the same content in the markdown.
- fluidcruft 3y agoI typically don't find docstrings are particularly useful for documenting an analysis or understanding what a function is doing. Even analyses that are repeated with different data. When you are debugging or reviewing an analysis, the docstrings are the least of your concerns. Validity is far more important. I would take a notebook that demonstrates what's happening to my data any day over a docstring that may or may not be correct. Particularly if I have to render it in yet a third system to juggle and manually keep in sync. So we've gone from notebooks to... notebook + py + docstring... I'm sure we can think of another useless layer of indirection to bolt on.
- spywaregorilla 3y ago> Particularly if I have to render it in yet a third system to juggle and manually keep in sync. I'm not sure you know what a docstring is if this is your response.
- fluidcruft 3y agoIf you are putting your docstrings in the py and they contain things like equations or figures or images, you have to render them to get the same effect that you would have just reviewing cells in the notebook. And as far as I know you can't even spread docstrings out over the body of a functions, the way you could if you broke the function up into cells. Docstrings are not literate programming.
- spywaregorilla 3y ago> And as far as I know you can't even spread docstrings out over the body of a functions, I really feel like you do not understand what a docstring is. This does not make any sense. > the way you could if you broke the function up into cells If your logic is broken up across cells then you cannot use it anywhere but in that notebook...