[Python-bugs-list] [ python-Bugs-755564 ] Tutorial: 4.7.2 Keyword Arguments **name output order wrong
SourceForge.net
noreply@sourceforge.net
Mon, 16 Jun 2003 14:53:09 -0700
Bugs item #755564, was opened at 2003-06-17 00:53
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=755564&group_id=5470
Category: Documentation
Group: Not a Bug
Status: Open
Resolution: None
Priority: 5
Submitted By: Jan Mattila (kakkonen)
Assigned to: Nobody/Anonymous (nobody)
Summary: Tutorial: 4.7.2 Keyword Arguments **name output order wrong
Initial Comment:
In the Tutorial at chapter 4.7.2 Keyword Arguments,
there is an example about the formal parameter **name.
I'm quoting the whole thing, for quick reference:
--- begin extract from Tutorial ---
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
for kw in keywords.keys(): print kw, ':', keywords[kw]
It could be called like this:
cheeseshop('Limburger', "It's very runny, sir.",
"It's really very, VERY runny, sir.",
client='John Cleese',
shopkeeper='Michael Palin',
sketch='Cheese Shop Sketch')
and of course it would print:
-- 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
--- end extract from Tutorial ---
What it actually prints on my LFS 3.3 (linuxfromscratch)
based distribution with Python 2.1.3 is
--- begin print out of cheeseshop ---
-- 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
sketch : Cheese Shop Sketch
shopkeeper : Michael Palin
--- end print out of cheeseshop ---
The problem is that the keywords[kw] list order is
garbled. I tried stripping this function of the *arguments
formal parameter and I got the same result. I tried
different amounts of **keywords in different
aphabetical orders. The resulting order does not
seem to be random and does not seem to be aplhabetical
nor related to the length of the **keywords or anything
I could figure out.
It's probably not a typo (on my part), because I copied
the code straight from the Tutorial page.
Now, this is not really a bug in my opinion, so I'm not
expecting a fix, but I was just trying to read through
the Tutorial and try all the example code and got
stuck trying to figure how you could tell the print order
of a formal parameter **name -type's name[kw] list.
I was thinking, that maybe if someone of class wizard
or higher would care to indulge me in the reason for
this behaviour I could become enlightened on another
aspect of Python. I'm not expecting swift replies, since
this is a zero-priority glitch, but someone, somewhere,
someday, maybe? No? Okay. Just a thought...
So much for trying to make this short.
I managed to reproduce the problem on Python 1.5.2
on Red Hat Linux 7.3.2 on linux-i386
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=755564&group_id=5470