ankit.agniho3
Nov 20, 2015 - 00:06
Hi Guys,
I recently joined pythonista community. I need your help in executing a script on pythonista which I am able to run on my linux system. First find my below script :-
#Script to print lines using functions
from sys import argv
script, input = argv
def print_all(f):
print f.read()
def rewind(f):
f.seek(0)
def print_a_line(line_count, f):
print line_count, f.readline()
current_file = open(input)
print "First lets print the whole file:\n"
print_all(current_file)
print "Now lets rewind the file like tape"
rewind(current_file)
print "Lets print three Lines"
current_count = 1
print_a_line(current_count, current_file)
current_count = current_count + 1
print_a_line(current_count, current_file)
current_count = current_count + 1
print_a_line(current_count, current_file)
#END
On my linux system I use:-
$ python script-name file-name
Where file-name is a text file which is saved on my linux system.
Here I want to execute the same script in pythonista but don't know from where I can call the text file into the script.
Please help me understand.