import sys def main(): for arg in sys.argv: f = open(sys.argv[1]) # set f as name of text file for outerline in f: eachword = outerline.split() # set eachword as a list of each string in line if arg in eachword: # check if any args passed by user appear in eachword print(" ".join(eachword)) # print all of the line containing eachword found g = f # set g as f to use g instead of resetting f innerline() def innerline(): for everydep in eachword([2:-1]): g = f for innerline in g: eachword2 = innerline.split() # set eachword 2 as a separate list of each string in line if eachword in eachword2 # check if eachword and eachword2 are the same print(" ".join(eachword2[2:-1) # print any required transitive dependencies in that line if __name__ == '__main__': main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question