#25536: Add support for ptpython shell
--------------------------------------------+--------------------------
     Reporter:  mdsrosa                     |      Owner:  nobody
         Type:  New feature                 |     Status:  new
    Component:  Core (Management commands)  |    Version:  1.8
     Severity:  Normal                      |   Keywords:  python shell
 Triage Stage:  Unreviewed                  |  Has patch:  1
Easy pickings:  0                           |      UI/UX:  0
--------------------------------------------+--------------------------
 I would like to add support for the `ptpython` shell. `ptpython` is very
 powerful, lightweight shell for Python.
 https://github.com/jonathanslenders/ptpython.

 The implementation is very simple. I've already done this in my local
 clone of django in a local branch based from master. Here is the diff:

 {{{#!bash
 diff --git i/django/core/management/commands/shell.py
 w/django/core/management/commands/shell.py
 index d8bded0..e52af95 100644
 --- i/django/core/management/commands/shell.py
 +++ w/django/core/management/commands/shell.py
 @@ -4,13 +4,13 @@ from django.core.management.base import BaseCommand


  class Command(BaseCommand):
 -    help = "Runs a Python interactive interpreter. Tries to use IPython
 or bpython, if one of them is available."
 +    help = "Runs a Python interactive interpreter. Tries to use IPython,
 bpython or ptpython, if one of them is available."
      requires_system_checks = False
 -    shells = ['ipython', 'bpython']
 +    shells = ['ipython', 'bpython', 'ptpython']

      def add_arguments(self, parser):
          parser.add_argument('--plain', action='store_true', dest='plain',
 -            help='Tells Django to use plain Python, not IPython or
 bpython.')
 +            help='Tells Django to use plain Python, not IPython, bpython
 or ptpython.')
          parser.add_argument('--no-startup', action='store_true',
 dest='no_startup',
              help='When using plain Python, ignore the PYTHONSTARTUP
 environment variable and ~/.pythonrc.py script.')
          parser.add_argument('-i', '--interface', choices=self.shells,
 dest='interface',
 @@ -50,6 +50,10 @@ class Command(BaseCommand):
          import bpython
          bpython.embed()

 +    def ptpython(self):
 +        from ptpython.repl import embed
 +        embed(globals(), locals())
 +
      def run_shell(self, shell=None):
          available_shells = [shell] if shell else self.shells
 }}}

 I don't think tests are needed since I didn't find tests for the `ipython`
 and `bpython` shells.

--
Ticket URL: <https://code.djangoproject.com/ticket/25536>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.8d73ba6297b96b4a305cea8853514939%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to