[Tutor] Help please!

Emile van Sebille emile at fenx.com
Mon Jul 30 22:29:22 CEST 2012


On 7/30/2012 12:52 PM Victoria Homsy said...
> 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?
>
> def print_a_line(line_count, f):
>     print line_count, f.readline()


This function accepts two passed parameters, then prints the first, and 
reads and prints one line from the second.  Obviously, to work the first 
must be printable, and the second must provide a readline method.

*IF* you believe that the names selected accurately represent the intent 
of the function, you may come to the type of conclusions you reach below.

Emile



>
> 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.
>
> Many thanks in advance!
>
> Best,
>
> Victoria
>



More information about the Tutor mailing list