> Hello all! I have a very simple question but I'm very new to python. Could you > describe to me what the following piece of Python code says in English > please?
Welcome to the list and Python! When posting code in the future I recommend posting in plain text and not "rich" text or HTML. If you are using Yahoo! via web interface you can do this by the following link. http://www.emailquestions.com/yahoo-mail/4446-switch-yahoo-mail-between-rich-text-plain-text.html > > def print_a_line(line_count, f): > print line_count, f.readline() > > I understand that line_count counts the number of lines in the Python prog, > and that we are creating a function, and that 'f' stands for file etc, but I > can't get my head around what the function does. line_count in this function can be anything. It is not actually doing any counting or any work. All this function does is print whatever information is in line_count (I assume it would be the current line number), then it retrieves exactly one line from the file f and then prints that line. Let us assume that the following multi-line string is what is contained in file f. Some examples of what this function would print are shown below. '''This is the first line. And this is the second line. ''' >>> print_a_line(1, f ) 1 This is the first line. >>> print_a_line('line 2:', f ) line 2: And this is the second line. Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor