[Tutor] Question on joining out of order dictionary elements

Andrew Robert andrew.arobert at gmail.com
Thu Jan 11 15:15:04 CET 2007


I like this solution.

Thanks everyone for all of the suggestions.

On 1/11/07, Andre Engels <andreengels at gmail.com> wrote:
> 2007/1/11, raghu raghu <vgvr620034 at gmail.com>:
>
> > >>> print "\\".join((config["val2"]
> > ,config["val1"],config["val3"]))
> > elem2\elem1\elem3
> >
> > or
> >
> > >>> print "%s\\%s\\%s" %
> (config["val2"],config["val1"],config["val3"])
> > elem2\elem1\elem3
> >
> > but this seems somehow uneligent.
> >
> > Are there a more efficient/compact ways of doing this kind of
> > operation or is this it?
> >
>
> Maybe you like:
> print "\\".join([config[val] for val in ["val2","val1","val3"]])
>
> --
> Andre Engels, andreengels at gmail.com
> ICQ: 6260644  --  Skype: a_engels
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>


-- 
Thank you,
Andrew Robert

Senior MQ Engineer
Information Technologies
Massachusetts Financial Services
Phone: 617-954-5882


More information about the Tutor mailing list