Loading ...
Sorry, an error occurred while loading the content.

[RFC] Adding alias command to ease supporting Python 2 and 3.

Expand Messages
  • Naoki INADA
    Hi, all. Sadly, if_python and if_python3 is exclusive on Linux. Writing plugin supporting both is difficult. I found jedi-vim
    Message 1 of 7 , Mar 31, 2013
    • 0 Attachment
      Hi, all.

      Sadly, if_python and if_python3 is exclusive on Linux.
      Writing plugin supporting both is difficult.

      I found jedi-vim (https://github.com/davidhalter/jedi-vim ) supports both of
      python 2 and 3.
      https://github.com/davidhalter/jedi-vim/blob/master/autoload/jedi.vim#L162


      Could vim have such alias command by default to ease writing such plugins?

      if has('python')
      command! -nargs=1 pythonx python <args>
      command! -nargs=1 pyfilex pyfile <args>
      let g:has_pythonx=1
      elseif has('python3')
      command! -nargs=1 pythonx python3 <args>
      command! -nargs=1 pyfilex py3file <args>
      let g:has_pythonx=1
      else
      let g:has_pythonx=0
      end

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • mattn
      I prefer rename python in current to python2, And define aliased command python . And I think that command must not be modifiable for users. So :python is
      Message 2 of 7 , Apr 2, 2013
      • 0 Attachment
        I prefer rename python in current to python2, And define aliased command 'python'.
        And I think that command must not be modifiable for users.
        So :python is specified python2 or python3 if it possible. And if both are enabled, I prefer it's python3.

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Paul Moore
        ... I agree. Python 3 is becoming more common, so at some point having python mean Python 2 will become obsolete. It requires some work to write Python
        Message 3 of 7 , Apr 4, 2013
        • 0 Attachment
          On Tuesday, 2 April 2013 12:28:40 UTC+1, mattn wrote:
          > I prefer rename python in current to python2, And define aliased command 'python'.
          > And I think that command must not be modifiable for users.
          > So :python is specified python2 or python3 if it possible. And if both are enabled, I prefer it's python3.

          I agree. Python 3 is becoming more common, so at some point having "python" mean "Python 2" will become obsolete. It requires some work to write Python code that is portable between Python 2 and 3, but it is certainly possible (and indeed it is the recommended approach to writing Python code that is portable between 2 and 3 these days).

          Very definitely, having :python mean "whichever of Python 2 or 3 is compiled in" makes sense.

          Paul.

          --
          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Naoki INADA
          I agree with you. ... I feel it is too aggressive for right now. I prefer :python means oldest python always and just wait python2 disabled on most platforms.
          Message 4 of 7 , Apr 4, 2013
          • 0 Attachment
            I agree with you.

            > > So :python is specified python2 or python3 if it possible. And if both are enabled, I prefer it's python3.

            I feel it is too aggressive for right now.
            I prefer :python means oldest python always and just wait python2 disabled on most platforms.

            2013年4月4日木曜日 18時37分06秒 UTC+9 Paul Moore:
            > On Tuesday, 2 April 2013 12:28:40 UTC+1, mattn wrote:
            > > I prefer rename python in current to python2, And define aliased command 'python'.
            > > And I think that command must not be modifiable for users.
            > > So :python is specified python2 or python3 if it possible. And if both are enabled, I prefer it's python3.
            >
            > I agree. Python 3 is becoming more common, so at some point having "python" mean "Python 2" will become obsolete. It requires some work to write Python code that is portable between Python 2 and 3, but it is certainly possible (and indeed it is the recommended approach to writing Python code that is portable between 2 and 3 these days).
            >
            > Very definitely, having :python mean "whichever of Python 2 or 3 is compiled in" makes sense.
            >
            > Paul.

            --
            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Bram Moolenaar
            ... Actually it doesn t. Python 2 and 3 are not compatible. You can t use ... always mean Python 2. Otherwise some percentage of the scripts will just not
            Message 5 of 7 , Apr 4, 2013
            • 0 Attachment
              Paul Moore wrote:

              > On Tuesday, 2 April 2013 12:28:40 UTC+1, mattn wrote:
              > > I prefer rename python in current to python2, And define aliased command 'python'.
              > > And I think that command must not be modifiable for users.
              > > So :python is specified python2 or python3 if it possible. And if both are enabled, I prefer it's python3.
              >
              > I agree. Python 3 is becoming more common, so at some point having "python" mean "Python 2" will become obsolete. It requires some work to write Python code that is portable between Python 2 and 3, but it is certainly possible (and indeed it is the recommended approach to writing Python code that is portable between 2 and 3 these days).
              >
              > Very definitely, having :python mean "whichever of Python 2 or 3 is
              > compiled in" makes sense.

              Actually it doesn't. Python 2 and 3 are not compatible. You can't use
              :python without knowing what version it is. Therefore :python will
              always mean Python 2. Otherwise some percentage of the scripts will
              just not work.

              If you don't like this, complain to those who decided to make Python 3
              not compatible with Python 2.

              --
              "A clear conscience is usually the sign of a bad memory."
              -- Steven Wright

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ an exciting new programming language -- http://www.Zimbu.org ///
              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

              --
              --
              You received this message from the "vim_dev" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_dev" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • INADA Naoki
              You re right, but... Actually it doesn t. Python 2 and 3 are not compatible. You can t use ... These days, many Python libraries support both of Python 2 and
              Message 6 of 7 , Apr 4, 2013
              • 0 Attachment
                You're right, but...

                Actually it doesn't.  Python 2 and 3 are not compatible.  You can't use
                :python  without knowing what version it is.

                These days, many Python libraries support both of Python 2 and 3 in one source.
                For those, Python 2 and 3 are compatible at some level.

                Jedi-vim uses alias command like this:
                
                
                if has('python')
                    command! -nargs=1 Python python <args>
                else
                    command! -nargs=1 Python python3 <args>
                end

                But, user defined commands can't be script/plugin local.
                So having standard command like it is good idea.

                 
                 Therefore :python will
                always mean Python 2.  Otherwise some percentage of the scripts will
                just not work.

                If vim is build with -python +python3, those script just not work, too.
                So, :python fallback to python3 doesn't break any scripts.
                 

                --
                INADA Naoki  <songofacandy@...>

                --
                --
                You received this message from the "vim_dev" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php
                 
                ---
                You received this message because you are subscribed to the Google Groups "vim_dev" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
                 
                 
              • Naoki INADA
                This path makes :python fallback to :pytohn3 when -python and +python3. -- -- You received this message from the vim_dev maillist. Do not top-post! Type your
                Message 7 of 7 , Apr 5, 2013
                • 0 Attachment
                  This path makes :python fallback to :pytohn3 when -python and +python3.

                  --
                  --
                  You received this message from the "vim_dev" maillist.
                  Do not top-post! Type your reply below the text you are replying to.
                  For more information, visit http://www.vim.org/maillist.php

                  ---
                  You received this message because you are subscribed to the Google Groups "vim_dev" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                Your message has been successfully submitted and would be delivered to recipients shortly.