Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32328 > unrolled thread

question on subprogram parameter

Started byskyworld <chenyong20000@gmail.com>
First post2012-10-28 20:03 -0700
Last post2012-10-29 03:35 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  question on subprogram parameter skyworld <chenyong20000@gmail.com> - 2012-10-28 20:03 -0700
    Re: question on subprogram parameter MRAB <python@mrabarnett.plus.com> - 2012-10-29 03:35 +0000

#32328 — question on subprogram parameter

Fromskyworld <chenyong20000@gmail.com>
Date2012-10-28 20:03 -0700
Subjectquestion on subprogram parameter
Message-ID<2a501243-836f-417f-b67a-365c0c777ddb@i2g2000pbi.googlegroups.com>
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.

[toc] | [next] | [standalone]


#32330

FromMRAB <python@mrabarnett.plus.com>
Date2012-10-29 03:35 +0000
Message-ID<mailman.2985.1351481728.27098.python-list@python.org>
In reply to#32328
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!

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web