GIDForums  

Go Back   GIDForums > Computer Programming Forums > Python Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 10-Mar-2007, 17:15
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,671
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice
Post

Re: Beginning Python Tutorial (Part 10)


I just posted a GID Community blog entitled: Beginning Python Tutorial (Part 10).

Quote:
Welcome back

Well, it's been quite some time since my last Python tutorial. I got sidetracked by actually trying to make some programs using Python. Some worked well, some not so well. But I learned from my mistakes and have a better grasp of how to use Python. read more...

Please let me know what you think.

This is an auto-generated message posted by GIDNetwork™ on behalf of the author.
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.

Interested in pen & paper role playing games from the "golden age" of gaming? Visit Old School Role-Playing Games
  #2  
Old 10-Mar-2007, 21:08
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,671
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: Beginning Python Tutorial (Part 10)


Hmm, looks like there's something wrong w/ the indenting mechanism in the second paragraph.
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.

Interested in pen & paper role playing games from the "golden age" of gaming? Visit Old School Role-Playing Games
  #3  
Old 10-Mar-2007, 21:52
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 1,049
admin will become famous soon enough

Keyword Arguments


In one paragraph, you wrote:

Quote:
You can also use keyword arguments, which match arguments based on a corresponding keyword. This way, you don't have to worry about the order they are given.

What does that mean? Can we have an example?
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #4  
Old 11-Mar-2007, 00:40
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,671
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: Keyword Arguments


Oops, I was going to come back to that but forgot.

Keyword arguments are similar to default arguments, wherein a default value is assigned to each keyword. The function can use either the default value for the keyword or a new value can be assigned using the standard keyword = value. Using keyword arguments eliminates the need to match a value to an argument's position, like the normal default values do.

Here's an example from the book Python How to Program:
Python Code:
def generateWebsite(name, url = "www.deitel.com", Flash = "no", CGI = "yes"):
    print "Generating site requested by", name, "using url", url
    if Flash == "yes":
        print "Flash is enable"
    if CGI == "yes":
        print "CGI scripts are enabled"

generateWebsite("Deitel")    #corresponds to 'name'

generateWebsite("Deitel", Flash = "yes", url = "www.deitel.com/new")

generateWebsite(CGI = "no", name = "Prentice Hall")
So, use keyword arguments when you want to pass in values but don't know what the argument's position is in the function definition. If you know the positions will be matched, you can just pass arguments in sequential order.
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.

Interested in pen & paper role playing games from the "golden age" of gaming? Visit Old School Role-Playing Games
  #5  
Old 11-Mar-2007, 00:48
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,671
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: Beginning Python Tutorial (Part 10)


Quote:
Originally Posted by crystalattice
Hmm, looks like there's something wrong w/ the indenting mechanism in the second paragraph.
Never mind. It's just a browser issue.
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.

Interested in pen & paper role playing games from the "golden age" of gaming? Visit Old School Role-Playing Games
  #6  
Old 11-Mar-2007, 02:19
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 1,049
admin will become famous soon enough

Re: Keyword Arguments


I get it now. Thank you

I think this keyword arguments thingy is so cool. This is the first time I am seeing something like this.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Beginning Python Tutorial (Part 5) crystalattice Python Forum 2 10-Jan-2017 10:45
Re: Beginning Python Tutorial (Part 9) crystalattice Python Forum 0 19-Feb-2006 02:04
Re: Beginning Python Tutorial (Part 6) crystalattice Python Forum 0 05-Oct-2005 18:48
Re: Beginning Python Tutorial (Part 2) crystalattice Python Forum 2 31-Jul-2005 12:25

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 10:43.


vBulletin, Copyright © 2000 - 2017, Jelsoft Enterprises Ltd.