Dive into Python question

F

Fred C. Dobbs

I feel like an idiot. I'm going thru "Dive Into Python" and running the
first program - odbchelper.py

My output is "pwd=secret;database=master;uid=sa;server=mpilgrim" which
has all the substrings reversed from the output documented in the book.
I've run the downloaded code in Komodo, PythonWin and the command line
and get the same results.

Have I set some switch on my python install that reverses everything?
 
S

Simon Forman

Fred said:
I feel like an idiot. I'm going thru "Dive Into Python" and running the
first program - odbchelper.py

My output is "pwd=secret;database=master;uid=sa;server=mpilgrim" which
has all the substrings reversed from the output documented in the book.
I've run the downloaded code in Komodo, PythonWin and the command line
and get the same results.

Have I set some switch on my python install that reverses everything?

Yeah, that's the '-esrever' switch...

Sorry, just kidding.

Your code's working fine. The thing is dicts do not guarantee any
particular order to their data when you access it. If you were to
delete a key-value pair and then set it again and print out your dict
again it would quite likely appear in a different order.

I've only ever skimmed DiP, but I'm sure Mark will get to that detail,
probably in section 3.1.

Peace,
~Simon
 
F

Fred C. Dobbs

Thanks, after I looked into it I realized that the output order can
change arbitarily. It just seems kind of strange that the first example
is one where your output might not match what the author tells you it
should be - and yet there's no mention of this in the book (at least at
that point.)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top