Newbie Questions: Swithing from Perl to Python

John J. Lee jjl at pobox.com
Sun Oct 26 09:01:32 EST 2003


Todd Stephens <huzzah at tampabay.rr.com> writes:

> On Sat, 25 Oct 2003 21:34:23 -0400, Luther Barnum wrote:
> 
> > 2. How can I sort and print out a hash.
[...]
> Well, as a Python learner myself, I am going to attempt this for my own
> education as well.  I think you are looking for a dictionary in Python.
> Let's say you have a dictionary 'dict' that contains something like this:
> 
> >>> dict = {'a':'me', 'b':'myself', 'c':'I'}

Calling a dictionary 'dict' is bad because dict is the type of a
dictionary in 2.2 and above:

>>> from types import DictType
>>> dict is DictType is type({})
True

So by assigning to dict, you're clobbering that name.


John




More information about the Python-list mailing list