🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #9606

vraagje ivm python

#9606
From: Vincent Spruyt
Date: Thu, 18 Apr 2002 15:27
34 lines
2187 bytes
Tot nu toe ging het goed ;-)
Maar nu begrjip ik toch iets niet zo goed.
dit is de defenition;

def cheeseshop(kind, *arguments, **keywords):
    print "-- Do you have any", kind, '?'
    print "-- I'm sorry, we're all out of", kind
    for arg in arguments: print arg
    print '-'*40
    keys = keywords.keys()
    keys.sort()
    for kw in keys: print kw, ':', keywords[kw]

wordt aangeroepen door:

cheeseshop('Limburger', "It's very runny, sir.",
           "It's really very, VERY runny, sir.",
           client='John Cleese',
           shopkeeper='Michael Palin',
           sketch='Cheese Shop Sketch')

En het resultaat is:
-- Do you have any Limburger ?
-- I'm sorry, we're all out of Limburger
It's very runny, sir.
It's really very, VERY runny, sir.
----------------------------------------
client : John Cleese
shopkeeper : Michael Palin
sketch : Cheese Shop Sketch
Nu staat er nergens uitleg over die **keywords en *arguments. Wat ik niet
begrijp in de def is het volgende.def [knip]    keys = keywords.keys()
[knip]Is keys hier een variabele, en kan dat evengoed test zijn? Is
keywords.keys() een functie? Wat doet dat juist?thxgreetz
Technical Details
Message-ID: <GBBv8.25175$Ze.4982@afrodite.telenet-ops.be>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.online.be!skynet.be!skynet.be!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fcea4,5958348cd08f8609,start
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2002-04-18 08:36:25 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.online.be!skynet.be!skynet.be!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mail
From: "Vincent Spruyt" <webmaster@flash-design.be>
Newsgroups: be.comp.programming
Subject: vraagje ivm python
Lines: 37
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <GBBv8.25175$Ze.4982@afrodite.telenet-ops.be>
Date: Thu, 18 Apr 2002 15:27:34 GMT
NNTP-Posting-Host: 213.224.248.71
X-Complaints-To: abuse@telenet.be
X-Trace: afrodite.telenet-ops.be 1019143654 213.224.248.71 (Thu, 18 Apr 2002 17:27:34 MET DST)
NNTP-Posting-Date: Thu, 18 Apr 2002 17:27:34 MET DST
Organization: Telenet Internet