omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Using argv

    Pythonista
    4
    6
    2290
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JasonN
      JasonN last edited by JasonN

      Hi there,

      I'm just delving into python and I'm a bit stuck with argv. I understand how to use it with the command line on my computer but how does it work exactly in Pythonista.

      For example, this small script passes in the name of the script and three variables, first, second and third but how do I do that with Pythonista?

      from sys import argv
      
      script, first, second, third = argv
      
      print "\n"
      
      print "The script is called:", script
      print "\n"
      print "Your first variable is:", first
      print "\n"
      print "Your second variable is:", second
      print "\n"
      print "Your third variable is:", third
      
      print "\n"
      

      Any help appreciated.

      Kind Regards

      1 Reply Last reply Reply Quote 0
      • JasonN
        JasonN last edited by

        Ah, I figured it out.

        kevinspacely 1 Reply Last reply Reply Quote 0
        • kevinspacely
          kevinspacely last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • kevinspacely
            kevinspacely @JasonN last edited by

            @JasonN How did you figure this out?

            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @kevinspacely last edited by

              @kevinspacely script is ok for Python 2

              Put as 1st line

              #!python2
              

              And test so

              1 Reply Last reply Reply Quote 0
              • ccc
                ccc last edited by

                There is also a 2to3 button under the wrench icon. Funny because there are exactly 223 days until Python 2 end of life!!

                1 Reply Last reply Reply Quote 2
                • First post
                  Last post
                Powered by NodeBB Forums | Contributors