Adding ptpython to the manage.py shell command

One thing that has changed my opinion here a bit is that Python 3.13 has some quite significant improvements to the shell, most of which are the most important things that I like ipython and ptpython for, so I now lean a bit more towards removing the support. (removing the whole shell command? Not sure about that…)

With that said, I haven’t actually tried it :slight_smile:

1 Like

I’ve been suggested a different approach to having a list of shells supported in Python, which is making it pluggable.

This basically would be the same as the PYTHONSTARTUP env variable. However, to make it easier, it would be a new option in the command, like
python manage.py --startup-file=shell-startup.py This file would contain the code required to import the shell, so for IPython

        from IPython import start_ipython

        start_ipython(argv=[])

This would avoid most of the maintenance problem while also allowing an easy way to do it.

I’m not sure yet how it would work with the autoimports new feature, but initially it could be that if you use a custom shells there’s no autoimports.

The main argument against would be that this is redundant with PYTHONSTARTUP but it could be a middle ground between removing it and adding new shells, while providing an easier way to do it.

TIL. I’ve never used the PYTHONSTARTUP env variable. I’m going to have to play with that.

To the extent that we can use custom shells (and achieve auto-imports?) by using this option, it surely beats building a replacement/duplicate?

TBH I can’t even seeing blog posts on this topic: it might be a good thing to write up using PYTHONSTARTUP as a demo of what’s possible? (I could imagine such making Django News.) From there we can regroup to see what (if anything) is left for Django to add.

I don’t see that it would hurt to add similar examples to the Django docs, so folks can learn that this feature exists, and how they can use it in their work.