omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. JasonN

    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.


    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 5
    • Best 0
    • Controversial 0
    • Groups 0

    JasonN

    @JasonN

    0
    Reputation
    368
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    JasonN Unfollow Follow

    Latest posts made by JasonN

    • RE: Just Print File Name

      Thank you @cvp

      posted in Pythonista
      JasonN
      JasonN
    • RE: Just Print File Name

      Here is what i now have but it still throws an error.

      from sys import argv
      
      from os.path.basename(/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/kl.py)
      
      script, file_from, file_to = argv
      
      source = open(file_from)
      source_data = source.read()
      
      print "'%s' is %s bytes." % (script, len(source_data))
      
      destination = open(file_to, 'w')
      destination.write(source_data)
      
      source.close()
      destination.close()```
      posted in Pythonista
      JasonN
      JasonN
    • Just Print File Name

      Hi there,

      When I run this simple script, everything works just fine but Pythonista prints the file location instead of just the file name. Does anyone know how to just print the file name? I'm assuming this is an iOS application thing because I don't have the same problem running it through Terminal on the Mac.

      Here's the script:

      from sys import argv
      
      script, file_from, file_to = argv
      
      source = open(file_from)
      source_data = source.read()
      
      print "'%s' is %s bytes." % (script, len(source_data))
      
      destination = open(file_to, 'w')
      destination.write(source_data)
      
      source.close()
      destination.close()
      

      Instead of printing the file name, I get something like:

      /Private/var/mobile/Library/Mobile Documents/iCloud etc

      posted in Pythonista
      JasonN
      JasonN
    • RE: Using argv

      Ah, I figured it out.

      posted in Pythonista
      JasonN
      JasonN
    • Using argv

      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

      posted in Pythonista
      JasonN
      JasonN