Saturday, 15 September 2012

What does this line have to do with anything? Python -



What does this line have to do with anything? Python -

from sys import argv script, filename = argv #line 2 , 5 correspound name "filename" txt = open(filename) print "here's file %r" % filename print txt.read() #line 5 corresponds line... ".read" python function print "type file name again:" file_again = raw_input("> ") txt_again = open(file_again) print txt_again.read()

how file_again = raw_input("> ") correspound line bellow it, , file_again stand for?

raw_input prompt user come in something. before doing that, print out argument. in case, > printed first, user can come in file name. whatever user entered returned raw_input , stored in file_again variable. used argument open opens file name.

python

No comments:

Post a Comment