[python-win32] Dictionary command
Tim Roberts
timr at probo.com
Wed Nov 17 20:21:07 CET 2004
On Wed, 17 Nov 2004 11:07:26 +0500, "Naveed Ahmed Khan"
<naveed48 at wol.net.pk> wrote:
> Dear friends, Thanks a lot for your help my problem is solved. Though
> I am afraid to tell you of my real blunder. I mean you must understand
> that it's my first time with programming. I was trying to achieve the
> following:
>
>>>>>>> dict = {}
>>>>>>> dict['boolean'] = "A value which is either true or false"
>>>>>>> dict['integer'] = "A whole number"
>>>>>>> print dict['boolean']
>>>>
>>>>
>A value which is either true or false
>
>What I was doing was that I was writing dict = () instead of dict = {}, got
>it, I was using the wrong bracket.
>
>
There is another problem with this. "dict" is the name of a built-in
type, along with "int", "str", "list", "tuple", and probably a couple
more. It can be used, for example, to convert a list of pairs to a
dictionary:
xyz = dict( ( ('boolean', True), ('integer', 3 ) ) )
By naming your variable "dict", you have hidden the built-in meaning of
that word. You should choose another name.
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-win32
mailing list