[Tutor] Creating a dictionary
spawgi at gmail.com
spawgi at gmail.com
Fri May 27 16:05:20 CEST 2011
The first approach does not really give you any variable (in easy form) to
operate upon.
The second approach returns a dict object that you can later reuse in easier
form. So one advantage is certainly that ease of object reuse and also
object modification.
If you want to add, remove, update anything in the dict object, the second
syntax is easier. You can also make it part of a class or module. You can
pass it to a function as well.
Regards
SWP
2011/5/27 Válas Péter <sulinet at postafiok.hu>
> Hi,
> I think I am new to here, as far as I remember. :-)
>
> http://docs.python.org/dev/library/stdtypes.html#dict says:
> we can create a dictionary with
>
> - dict({'one': 1, 'two': 2})
>
> What is the adventage of this form to simply writing d = {'one': 1, 'two': 2}?
> Is there any difference?
>
> Thanks
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
--
http://spawgi.wordpress.com
We can do it and do it better.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110527/a9b523f1/attachment.html>
More information about the Tutor
mailing list