question on subprogram parameter

Discussion in 'Python' started by skyworld, Oct 29, 2012.

  1. skyworld

    skyworld Guest

    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.
    skyworld, Oct 29, 2012
    #1
    1. Advertising

  2. skyworld

    MRAB Guest

    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!
    MRAB, Oct 29, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Jones

    Hiding of subprogram designators

    David Jones, Nov 17, 2003, in forum: VHDL
    Replies:
    1
    Views:
    557
    Alan Fitch
    Nov 18, 2003
  2. Taras_96
    Replies:
    2
    Views:
    4,871
    Taras_96
    Aug 3, 2005
  3. =?ISO-8859-1?Q?Sch=FCle_Daniel?=

    subprogram parameter list

    =?ISO-8859-1?Q?Sch=FCle_Daniel?=, Jul 9, 2006, in forum: VHDL
    Replies:
    3
    Views:
    534
    john Doef
    Jul 13, 2006
  4. Replies:
    1
    Views:
    680
    Paul Uiterlinden
    Sep 8, 2006
  5. John Smith
    Replies:
    10
    Views:
    792
    Jonathan Bromley
    Jul 3, 2007
Loading...

Share This Page