This has turned into a very interesting discussion. Thank you to everyone who's participating and sharing nuggets of information on 2 vs 3.
On Mon, Sep 7, 2015 at 1:58 PM, Steven D'Aprano <st...@pearwood.info> wrote: > On Mon, Sep 07, 2015 at 11:01:00AM +0100, Alan Gauld wrote: > > On 07/09/15 10:32, Laura Creighton wrote: > > >In a message of Mon, 07 Sep 2015 10:16:16 +0100, Alan Gauld writes: > > > > > >>And of course if you are really moving to the v3 way of > > >>doing things you should move to using the new string > > >>formatting style. > > > > > >I don't think there is any great push to prefer the new style over > > >the old style 'just because' when you are doing simple things. > > > > No 'big push' because there's too much historic code out there. > > But I thought I'd read somewhere when it first came out that > > the old style was deprecated? But I may be hallucinating! :-) > > When the format() method first came out, there was talk about > deprecating % formatting, but it was only talk and never became > official. > > > OTOH the new style brings enough benefits, especially in the > > areas of dynamic formatting, that I'd strongly suggest moving > > to it if you are making the jump to v3 anyway! > > It's worth learning both formatting systems, even if you're just using > Python 2. The format method started in 2.6, and 2.7 added the > "autonumbering" feature that makes it much easier to use: > > "{0} {1} {2}".format(a, b, c) # needed in 2.6 > "{} {} {}".format(a, b, c) # 2.7 and up > > > Having said that, I still don't know how to use format other than the > basics, as most of the code I write has to be compatible with 2.4 > onwards. > > > > -- > Steve > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- Kind regards, Sithu Lloyd Dube _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor