question on subprogram parameter
MRAB
python at mrabarnett.plus.com
Sun Oct 28 23:35:27 EDT 2012
On 2012-10-29 03:03, skyworld wrote:
> Hi,
>
> I'm studying python now and I saw a piece of code like this:
>
> def storeDbase(db, dbfilename=dbfilename):
> .....
> dbfile=open(dbfilename,'w')
> for key in db:
> print(key, file=dbfile)
>
>
> can anybody help me to understand what does this "file=dbfile" mean
> and what is its function? thanks.
>
It's a keyword parameter.
Normally 'print' sends its output to the standard output (usually it's
the screen).
Adding 'file=dbfile' tells it to send its output to the file referred
to by 'dbfile' instead.
It's all in the documentation!
More information about the Python-list
mailing list