python2 autocompletes file names on BASH shell, python3 does not

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite
1












When I type at the BASH terminal, I am accustomed to typing "python a_long_filename.py" but always using the "tab->" key to autocomplete the file name, which saves me time with typos. This works with python2, but not with python3.



is there some package I can install, or some setting I can change, to enable the autocomplete for python3?










share|improve this question





















  • What is the output of complete -p python3?
    – wjandrea
    Mar 20 at 18:53










  • output bash: complete: python3: no completion specification but complete -p python outputs the same
    – con
    Mar 20 at 18:55











  • Just to clarify one thing, Bash is doing the completion. Read help complete for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.
    – wjandrea
    Mar 20 at 18:57










  • this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
    – con
    Mar 20 at 19:00










  • After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: type python, then a space, then press Tab, then erase it, and run complete -p python python2 python3 (python and python2 added for good measure).
    – wjandrea
    Mar 20 at 19:10















up vote
1
down vote

favorite
1












When I type at the BASH terminal, I am accustomed to typing "python a_long_filename.py" but always using the "tab->" key to autocomplete the file name, which saves me time with typos. This works with python2, but not with python3.



is there some package I can install, or some setting I can change, to enable the autocomplete for python3?










share|improve this question





















  • What is the output of complete -p python3?
    – wjandrea
    Mar 20 at 18:53










  • output bash: complete: python3: no completion specification but complete -p python outputs the same
    – con
    Mar 20 at 18:55











  • Just to clarify one thing, Bash is doing the completion. Read help complete for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.
    – wjandrea
    Mar 20 at 18:57










  • this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
    – con
    Mar 20 at 19:00










  • After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: type python, then a space, then press Tab, then erase it, and run complete -p python python2 python3 (python and python2 added for good measure).
    – wjandrea
    Mar 20 at 19:10













up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





When I type at the BASH terminal, I am accustomed to typing "python a_long_filename.py" but always using the "tab->" key to autocomplete the file name, which saves me time with typos. This works with python2, but not with python3.



is there some package I can install, or some setting I can change, to enable the autocomplete for python3?










share|improve this question













When I type at the BASH terminal, I am accustomed to typing "python a_long_filename.py" but always using the "tab->" key to autocomplete the file name, which saves me time with typos. This works with python2, but not with python3.



is there some package I can install, or some setting I can change, to enable the autocomplete for python3?







bash python






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 20 at 18:48









con

84




84











  • What is the output of complete -p python3?
    – wjandrea
    Mar 20 at 18:53










  • output bash: complete: python3: no completion specification but complete -p python outputs the same
    – con
    Mar 20 at 18:55











  • Just to clarify one thing, Bash is doing the completion. Read help complete for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.
    – wjandrea
    Mar 20 at 18:57










  • this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
    – con
    Mar 20 at 19:00










  • After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: type python, then a space, then press Tab, then erase it, and run complete -p python python2 python3 (python and python2 added for good measure).
    – wjandrea
    Mar 20 at 19:10

















  • What is the output of complete -p python3?
    – wjandrea
    Mar 20 at 18:53










  • output bash: complete: python3: no completion specification but complete -p python outputs the same
    – con
    Mar 20 at 18:55











  • Just to clarify one thing, Bash is doing the completion. Read help complete for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.
    – wjandrea
    Mar 20 at 18:57










  • this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
    – con
    Mar 20 at 19:00










  • After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: type python, then a space, then press Tab, then erase it, and run complete -p python python2 python3 (python and python2 added for good measure).
    – wjandrea
    Mar 20 at 19:10
















What is the output of complete -p python3?
– wjandrea
Mar 20 at 18:53




What is the output of complete -p python3?
– wjandrea
Mar 20 at 18:53












output bash: complete: python3: no completion specification but complete -p python outputs the same
– con
Mar 20 at 18:55





output bash: complete: python3: no completion specification but complete -p python outputs the same
– con
Mar 20 at 18:55













Just to clarify one thing, Bash is doing the completion. Read help complete for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.
– wjandrea
Mar 20 at 18:57




Just to clarify one thing, Bash is doing the completion. Read help complete for some info. So really the issue is that Bash autocompletes file names for python2 but not python3.
– wjandrea
Mar 20 at 18:57












this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
– con
Mar 20 at 19:00




this is Ubuntu 17.10, with GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
– con
Mar 20 at 19:00












After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: type python, then a space, then press Tab, then erase it, and run complete -p python python2 python3 (python and python2 added for good measure).
– wjandrea
Mar 20 at 19:10





After some testing, it seems like the completion settings don't get loaded until you try to use them. So try this in the terminal: type python, then a space, then press Tab, then erase it, and run complete -p python python2 python3 (python and python2 added for good measure).
– wjandrea
Mar 20 at 19:10











1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










As we discussed in the comments, you're trying to use Bash autocomplete on scripts with .py3 extensions. The problem is, Bash will only autocomplete scripts with .py extensions.



I recommend using .py extensions even for Python 3 scripts, since .py3 is non-standard. If the scripts require Python 3, you could...



  • Use the shebang: #!/usr/bin/env python3

  • Check if sys.version_info.major == 3

    • Or check if >= 3, to allow forwards compatibility


  • Maybe use from __future__ import ... to allow backwards compatibility





share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017714%2fpython2-autocompletes-file-names-on-bash-shell-python3-does-not%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote



    accepted










    As we discussed in the comments, you're trying to use Bash autocomplete on scripts with .py3 extensions. The problem is, Bash will only autocomplete scripts with .py extensions.



    I recommend using .py extensions even for Python 3 scripts, since .py3 is non-standard. If the scripts require Python 3, you could...



    • Use the shebang: #!/usr/bin/env python3

    • Check if sys.version_info.major == 3

      • Or check if >= 3, to allow forwards compatibility


    • Maybe use from __future__ import ... to allow backwards compatibility





    share|improve this answer


























      up vote
      3
      down vote



      accepted










      As we discussed in the comments, you're trying to use Bash autocomplete on scripts with .py3 extensions. The problem is, Bash will only autocomplete scripts with .py extensions.



      I recommend using .py extensions even for Python 3 scripts, since .py3 is non-standard. If the scripts require Python 3, you could...



      • Use the shebang: #!/usr/bin/env python3

      • Check if sys.version_info.major == 3

        • Or check if >= 3, to allow forwards compatibility


      • Maybe use from __future__ import ... to allow backwards compatibility





      share|improve this answer
























        up vote
        3
        down vote



        accepted







        up vote
        3
        down vote



        accepted






        As we discussed in the comments, you're trying to use Bash autocomplete on scripts with .py3 extensions. The problem is, Bash will only autocomplete scripts with .py extensions.



        I recommend using .py extensions even for Python 3 scripts, since .py3 is non-standard. If the scripts require Python 3, you could...



        • Use the shebang: #!/usr/bin/env python3

        • Check if sys.version_info.major == 3

          • Or check if >= 3, to allow forwards compatibility


        • Maybe use from __future__ import ... to allow backwards compatibility





        share|improve this answer














        As we discussed in the comments, you're trying to use Bash autocomplete on scripts with .py3 extensions. The problem is, Bash will only autocomplete scripts with .py extensions.



        I recommend using .py extensions even for Python 3 scripts, since .py3 is non-standard. If the scripts require Python 3, you could...



        • Use the shebang: #!/usr/bin/env python3

        • Check if sys.version_info.major == 3

          • Or check if >= 3, to allow forwards compatibility


        • Maybe use from __future__ import ... to allow backwards compatibility






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 20 at 20:01

























        answered Mar 20 at 19:48









        wjandrea

        7,19342255




        7,19342255



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017714%2fpython2-autocompletes-file-names-on-bash-shell-python3-does-not%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491