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 <suli...@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@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.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor