6 ms·
I've always hovered around iPython with a vague sense that it could be used in a really cool way, but have never managed to make the jump to incorporate it into
by nicpottier 13y ago
I've always hovered around iPython with a vague sense that it could be used in a really cool way, but have never managed to make the jump to incorporate it into my daily workflow despite some fun experiments.
It is much more clear how those using Python for scientific work would use it, but does anyone have some great examples on how you use it when building apps or other projects?
- yaph 13y agoA use case that is related to to (data) science work is scraping data from Web sites, which can of course be useful in other cases too. I got used to start and test those kind of scripts in IPython Notebook and once they work save them as a standalone script.
- paulgb 13y agoMy primary use of IPython is as an interactive environment, but I've used it in production in a couple ways: - I have a script that runs at midnight to fetch the last day's data and run an IPython notebook with runipy (https://pypi.python.org/pypi/runipy https://pypi.python.org/pypi/runipy). I render the notebook to HTML with nbconvert with a template that hides the Python code, and emails me the output. - I have a model that needs to be trained occasionally as part of a workflow. Rather than writing a python script, I use a notebook. After training the model I plot some graphs to evaluate/validate the model and these become part of an HTML report that gets generated alongside the model. I use runipy to automate the pipeline.
- adwn 13y agoI use it as a better shell. Scripting in bash or sh is a horrible experience, and pure Python lacks the conciseness of bash for simple exploration and manipulation of a file system hierarchy (cd, cp, mv, ls...). For example, you can write stuff like files = !ls -a for f in files: !diff $f "some_file" if _exit_code != 0: some_function(f) and it even correctly handles spaces in file names. (what sorcery is this?!)
- Cyph0n 13y agoThis changes everything!
- a3n 13y agoNot at all to pick a nit, but that still depends on bash or sh (the bang commands). Does anyone have any experience reports on using ipython as a better shell on top of cmd.exe rather than on top of a *nix shell?
- adwn 13y ago> Not at all to pick a nit, but that still depends on bash or sh (the bang commands). That's a good point, and not nit-picky at all. However, I think the dependency is on the Unix commands (mv, cp, ...), not bash or sh, which still makes this mixed approach unsuitable for truly platform-independent scripting. Of course, this point is moot when you use it as your personal shell, or when scripting for your Unix servers, etc.
- cben 13y agoNeat, works with #!/usr/bin/env ipython I'm using fish <http://fishshell.com/> http://fishshell.com/> for both scripting (saner syntax, space handling) and interactive (multiline syntax highlighted prompt) and never looked back. But this makes me consider ipython again, perhaps even as main shell. Hmm, after %rehashx I can use commands without !, e.g. git diff. <http://ipython.org/ipython-doc/stable/interactive/shell.html> http://ipython.org/ipython-doc/stable/interactive/shell.html... Moreover, this means I can have a notebook experience for my shell. Together with the new directory navigation and friendly URLs this is becoming very attractive! There is however a deal-breaker: no smart completion for shell commands. But it'd be clearly possible to implement it by harnessing bash (or zsh or fish) for completions.
- csense 13y agoWow. The one thing that makes bash scripting better than Python for certain things is that using the subprocess module makes your code really verbose. This fixes that.
- gallamine 13y agoI use it for blogging and documenting my work. Here's an example blog post I put together on compressed sensing: http://www.gallamine.com/2014/02/a-brief-introduction-to-compressed.html http://www.gallamine.com/2014/02/a-brief-introduction-to-com...
- nailer 13y agoipdb import ipdb Later: ipdb.set_trace() Look around. Inspect some stuff. Change some values. Write some prototype code. I have no idea how I debugged before ipdb, and my node suffers because node inspector isn't anywhere near as powerful. Seriously, it's awesome.