Re: ValueError: invalid literal for int():

2010-07-26 Thread lee
On Jul 26, 4:30 pm, Steven D'Aprano wrote: > On Mon, 26 Jul 2010 04:12:33 -0700, Chris Rebert wrote: > > On Mon, Jul 26, 2010 at 4:03 AM, Sunny chilgod > > wrote: > >> Hi Chris, > >> Thanks for your help. but i need to to convert the whole string to int. > >> heres my full code, > >> ptid = 'item

Re: ValueError: invalid literal for int():

2010-07-26 Thread Steven D'Aprano
On Mon, 26 Jul 2010 04:12:33 -0700, Chris Rebert wrote: > On Mon, Jul 26, 2010 at 4:03 AM, Sunny chilgod > wrote: >> Hi Chris, >> Thanks for your help. but i need to to convert the whole string to int. >> heres my full code, >> ptid = 'item_01bom' >> so item_01bom is a field name in form, so i ge

Re: ValueError: invalid literal for int():

2010-07-26 Thread Chris Rebert
> On Mon, Jul 26, 2010 at 4:25 PM, Chris Rebert wrote: >> On Mon, Jul 26, 2010 at 3:25 AM, lee wrote: >> > Hi, >> > >> > I have a value, >> > >> > partintid = int(Screw plugg  (91_10 -> untitled)) >> > >> > but i get ValueError: invalid literal for int(): Screw plugg  (91_10 - >> >> untitled) >>

Re: ValueError: invalid literal for int():

2010-07-26 Thread Sunny chilgod
Hi Chris, Thanks for your help. but i need to to convert the whole string to int. heres my full code, ptid = 'item_01bom' so item_01bom is a field name in form, so i get its value, partintid = int(form[ptid]). # the value of form[ptid] is 'Screw plugg (91_10 - untitled)' Hence i get the error

Re: ValueError: invalid literal for int():

2010-07-26 Thread Chris Rebert
On Mon, Jul 26, 2010 at 3:25 AM, lee wrote: > Hi, > > I have a value, > > partintid = int(Screw plugg  (91_10 -> untitled)) > > but i get ValueError: invalid literal for int(): Screw plugg  (91_10 - >> untitled) > any help? That is most certainly not your actual exact code, since it has a few Syn

Re: ValueError: invalid literal for int(): 1.0000000000e+00

2005-02-14 Thread Terry Reedy
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Terry Reedy wrote: >> int(somestring) without a radix argument requires that somestring be an >> decimal integer literal and nothing more and nothing else. > > but specifying a radix won't help you, though: My stateme

Re: ValueError: invalid literal for int(): 1.0000000000e+00

2005-02-14 Thread Fredrik Lundh
Terry Reedy wrote: > int(somestring) without a radix argument requires that somestring be an > decimal integer literal > and nothing more and nothing else. but specifying a radix won't help you, though: >>> int("1.0", 10) Traceback (most recent call last): File "", line 1, in ? ValueError: i

Re: ValueError: invalid literal for int(): 1.0000000000e+00

2005-02-14 Thread Terry Reedy
"Martin MOKREJ©" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] int(somestring) without a radix argument requires that somestring be an decimal integer literal and nothing more and nothing else. >>> int('1') 1 >>> int('1.0') Traceback (most recent call last): File "", line 1, in

Re: ValueError: invalid literal for int(): 1.0000000000e+00

2005-02-14 Thread Grant Edwards
On 2005-02-14, Martin MOKREJ© <[EMAIL PROTECTED]> wrote: > is this a bug or "feature" that I have to use float() to make int() > autoconvert > from it? It's a feature. Integers don't have decimal points... -- Grant Edwards grante Yow! I just had a NOSE

Re: ValueError: invalid literal for int(): 1.0000000000e+00

2005-02-14 Thread Fredrik Lundh
Martin MOKREJ© wrote: > is this a bug or "feature" that I have to use float() to make int() > autoconvert > from it? it's by design, of course. "1.00e+00" is not an integer. if you want to treat a floating point literal as an integer, you have to use an explicit conversion. --