Prev: can you say it please
Next: can python do this?
From: Mark Dickinson on 2 Dec 2009 13:32 On Dec 2, 4:41 pm, "John Posner" <jjpos...(a)optimum.net> wrote: > Goal: place integer 456 flush-right in a field of width 8 > > Py2: "%%%dd" % 8 % 456 > Py3: "{0:{1}d}".format(456, 8) > > With str.format(), you don't need to nest one formatting operation within > another. A little less mind-bending, and every little bit helps! Or even "{:{}d}".format(456, 8), in 3.1 and 2.7 (when it appears). But you can do this with % formatting, too. In either 2.x or 3.x: >>> "%*d" % (8, 456) ' 456' -- Mark
From: Carsten Haese on 2 Dec 2009 13:34 John Posner wrote: > Goal: place integer 456 flush-right in a field of width 8 > > Py2: "%%%dd" % 8 % 456 > Py3: "{0:{1}d}".format(456, 8) > > With str.format(), you don't need to nest one formatting operation > within another. With string interpolation, you don't need to do that, either. >>> '%*d' % (8,456) ' 456' -- Carsten Haese http://informixdb.sourceforge.net
From: David H Wild on 2 Dec 2009 14:28 In article <351fcb4c-4e88-41b0-a0aa-b3d63832d1aa(a)e23g2000yqd.googlegroups.com>, Mark Summerfield <list(a)qtrac.plus.com> wrote: > I only just found out that I was supposed to give a different URL: > http://www.informit.com/promotions/promotion.aspx?promo=137519 > This leads to a web page where you can download the document (just by > clicking the "Download Now" button), but if you _choose_ you can also > enter your name and email to win some sort of prize. There is a typographical fault on page 4 of this pdf file. The letter "P" is missing from the word "Python" at the head of the comparison columns. -- David Wild using RISC OS on broadband www.davidhwild.me.uk
From: John Bokma on 2 Dec 2009 14:50 Mark Summerfield <list(a)qtrac.plus.com> writes: > On 1 Dec, 23:52, John Bokma <j...(a)castleamber.com> wrote: >> Mark Summerfield <l...(a)qtrac.plus.com> writes: >> > It is available as a free PDF download (no registration or anything) >> > from InformIT's website. Here's the direct link: >> >http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/... >> >> Thanks! >> >> > And of course, if you want more on Python 3, there's always the >> > documentation---or my book:-) >> > "Programming in Python 3 (Second Edition)" ISBN-10: 0321680561. >> >> Meh, second edition already? Haven't read the entire first edition >> yet. Which is IMO a good book (I also gave it to my brother as a >> present). > > If it is any consolation, the second edition should have a much longer > life, now that we have the language moratorium. (I _really_ wanted to > cover 3.1.) Nah, I wasn't really complaining. Moreover, I am glad I didn't finish the first edition, so I have less of a problem starting in the 2nd edition from the beginning. From what I've read in the 1st edition it's an excellent book. >> Only negative point (to me) so far is that in the beginning (p8-9) the >> book mentions placing Python programs in C:\py3eg which gives me the >> unpleasant feeling that someone is coding on Windows XP with >> Administrator rights... > > OK, you got me there, I knew it ;-) Should've emailed you months ago and maybe it would have changed in the 2nd edition :-( > I only use Windows for testing purposes and my > personal logon account does have Administrator rights, which I assumed > was standard for personal machines? I use XP Professional and the first thing I do after installation is creating a limited user account for my day to day work. As far as I know this can also be done in XP Home, but I've no experience with home. > Also, the path is short. It is > only a suggestion, it really doesn't matter where you unpack the > examples. My issue with it is that it somewhat promotes working with Administrator rights, which is as dangerous as working with root rights on other OSes if the machine is not connected to the Internet. If it's connected to the Internet it's way more dangerous, sadly. Anyway, thanks for writing IMO a very good book, and I *am* happy with a second edition. -- John Bokma Read my blog: http://johnbokma.com/ Hire me (Perl/Python): http://castleamber.com/
From: Mark Summerfield on 2 Dec 2009 15:15
On 2 Dec, 19:28, David H Wild <dhw...(a)talktalk.net> wrote: > In article > <351fcb4c-4e88-41b0-a0aa-b3d63832d...(a)e23g2000yqd.googlegroups.com>, > Mark Summerfield <l...(a)qtrac.plus.com> wrote: > > > I only just found out that I was supposed to give a different URL: > >http://www.informit.com/promotions/promotion.aspx?promo=137519 > > This leads to a web page where you can download the document (just by > > clicking the "Download Now" button), but if you _choose_ you can also > > enter your name and email to win some sort of prize. > > There is a typographical fault on page 4 of this pdf file. The letter "P" > is missing from the word "Python" at the head of the comparison columns. I can't see that problem---I've tried the PDF with evince, gv, acroread, and okular, and no missing "P" on page 4. I don't have a machine with RISC OS on it so I can't test on that environment! > -- > David Wild using RISC OS on broadbandwww.davidhwild.me.uk |