Giter Club home page Giter Club logo

Comments (3)

kynan avatar kynan commented on July 23, 2024

You can achieve that with a simple sed command:

sed 's/In\[[0-9]\+\]:/In[ ]:/' yourfile.py

I don't think this is something nbstripout should handle. What is your use case / workflow?

from nbstripout.

adrach avatar adrach commented on July 23, 2024

either sed or a small python script would work. I use GIT on Windows and I have automatic saving of python copies of my notebooks setup in jupyter. I can certainly add this feature separately on my system, but I am sure there are quite a few people who use this feature of jupyter, and they would also need it.
What do you think?

from nbstripout.

kynan avatar kynan commented on July 23, 2024

I'm still not convinced nbstripout is the tool to handle this. It's really geared towards notebooks and having it handle Python scripts raises a number of questions:

  • Presumably you don't want to apply this filter to all Python scripts but only those exported from notebooks. So setting up the filter by file extension won't cut it.
  • nbstripout can (and does, when used as a Git filter) read from stdin and therefore doesn't even know the file extension.
  • Even if it did, that would not be safe, so it would need to detect the file type or be told via a flag.

I'd rather keep nbstripout focussed on notebooks and handle that case well than adding a feature to handle an edge case that will confuse the majority of users.

Why don't you set up that sed command as a filter for your Python scripts? Arguably you might not even want to track those in Git since they're automatically generated.

from nbstripout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.