[Tutor] dictionary

Rodrigues op73418@mail.telepac.pt
Tue Jun 24 11:23:01 2003


-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf
Of ajstec


>Hello all,
>
>I am trying to learn Python, and need of help, as I make to discover
all the attributes in the use of dictionaries.
>
>Eg : dict={'name' : 'joao'}
>       dict.has_key('name')
>
>attribute in red.
>
>

I'm not sure what is your question. So i'll make just two comments.

1. dict is a built-in so you should not use it as a variable.

>>> dict
<type 'dict'>
>>>

2. If you want to know the attributes of an object, fire up the
interactive prompt and use help.

>>> help(dict)
Help on class dict in module __builtin__:

class dict(object)
 |  dict() -> new empty dictionary.
 |  dict(mapping) -> new dictionary initialized from a mapping
object's
 |      (key, value) pairs.
 |  dict(seq) -> new dictionary initialized as if via:
 |      d = {}
 |      for k, v in seq:
 |          d[k] = v

[lots more snipped]

Of course, for builtins and standard modules you can also consult the
readily available documentation.

Hope it helps, with my best regards,
G. Rodrigues

P.S: Please, don't send HTML mail. Send it in plain text.

>Adilton,
>Recife-Brazil