Re: [Tutor] Leading zero for hex numbers

2004-12-15 Thread Orri Ganel
On Wed, 15 Dec 2004 20:40:40 -0500, R. Alan Monroe <[EMAIL PROTECTED]> wrote: > > print "0x%0X" % 12345 > > > displays > > 0x3039 > > > instead of 0x03039 > > > >>> "%05x" % (12345,) > '03039' > > >>> "0x%05x" % (12345,) > '0x03039' > > ___ > Tutor

Re: [Tutor] Leading zero for hex numbers

2004-12-15 Thread Bob Gailer
At 06:47 PM 12/15/2004, Tony Cappellini wrote: I'm trying to get Python to automatically print a leading 0 for hex numbers, but it only seems to work for for decimal numbers. Oh? print "%0d" % 12345 gives me 12345 - no leading 0 print "0x%0X" % 12345 displays 0x3039 which it should instead of 0x030

Re: [Tutor] Leading zero for hex numbers

2004-12-15 Thread Orri Ganel
On Wed, 15 Dec 2004 17:47:58 -0800 (PST), Tony Cappellini <[EMAIL PROTECTED]> wrote: > > I'm trying to get Python to automatically print a leading 0 for hex > numbers, but it only > seems to work for for decimal numbers. > > print "0x%0X" % 12345 > > displays > 0x3039 > > instead of 0x03039 >

Re: [Tutor] Leading zero for hex numbers

2004-12-15 Thread R. Alan Monroe
> print "0x%0X" % 12345 > displays > 0x3039 > instead of 0x03039 >>> "%05x" % (12345,) '03039' >>> "0x%05x" % (12345,) '0x03039' ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

[Tutor] Leading zero for hex numbers

2004-12-15 Thread Tony Cappellini
I'm trying to get Python to automatically print a leading 0 for hex numbers, but it only seems to work for for decimal numbers. print "0x%0X" % 12345 displays 0x3039 instead of 0x03039 The Python docs state The conversion will be zero padded for numeric values, when a 0 is used as a flag betw