Re: str(int_var) formatted

2010-11-01 Thread Lawrence D'Oliveiro
In message , John Yeung wrote: > I will give zfill a little exposure, as it seems unloved/underused: > > str(x).zfill(2) The inside of my brain is a finite place. Each thing I put in there leaves less room for something else. So I have to think very carefully before deciding what to keep in

Re: str(int_var) formatted

2010-10-30 Thread Tracubik
Il Fri, 29 Oct 2010 19:18:41 -0700, John Yeung ha scritto: > On Oct 29, 11:59 am, Tracubik wrote: >> i've to convert integer x to string, but if x < 10, the string have to >> be '0x' instead of simple 'x' >> >> for example: >> >> x = 9 >> str(x) --> '09' > > Everyone else seems to prefer the for

Re: str(int_var) formatted

2010-10-29 Thread John Yeung
On Oct 29, 11:59 am, Tracubik wrote: > i've to convert integer x to string, but if x < 10, > the string have to be '0x' instead of simple 'x' > > for example: > > x = 9 > str(x) --> '09' Everyone else seems to prefer the format-based solutions, which is fine. I will give zfill a little exposure,

Re: str(int_var) formatted

2010-10-29 Thread MRAB
On 29/10/2010 17:18, "none <"@mail.python.org wrote: On 29/10/10 16:59, Tracubik wrote: Hi all, i've to convert integer x to string, but if x< 10, the string have to be '0x' instead of simple 'x' for example: x = 9 str(x) --> '09' x = 32 str(x) --> '32' x represent hour/minute/second. I can

RE: str(int_var) formatted

2010-10-29 Thread Andreas Tawn
> Hi all, > i've to convert integer x to string, but if x < 10, the string have to > be > '0x' instead of simple 'x' > > for example: > > x = 9 > str(x) --> '09' > > x = 32 > str(x) --> '32' > > x represent hour/minute/second. > > I can easily add '0' with a if then block, but is there a built

Re: str(int_var) formatted

2010-10-29 Thread none
On 29/10/10 16:59, Tracubik wrote: Hi all, i've to convert integer x to string, but if x< 10, the string have to be '0x' instead of simple 'x' for example: x = 9 str(x) --> '09' x = 32 str(x) --> '32' x represent hour/minute/second. I can easily add '0' with a if then block, but is there

Re: str(int_var) formatted

2010-10-29 Thread Grant Edwards
On 2010-10-29, Tracubik wrote: > Hi all, > i've to convert integer x to string, but if x < 10, the string have to be > '0x' instead of simple 'x' > > for example: > > x = 9 > str(x) --> '09' > > x = 32 > str(x) --> '32' > > x represent hour/minute/second. > > I can easily add '0' with a if then b

str(int_var) formatted

2010-10-29 Thread Tracubik
Hi all, i've to convert integer x to string, but if x < 10, the string have to be '0x' instead of simple 'x' for example: x = 9 str(x) --> '09' x = 32 str(x) --> '32' x represent hour/minute/second. I can easily add '0' with a if then block, but is there a built-in way to add the '0' automat