Re: [Tutor] Limitation of int() in converting strings

2012-12-16 Thread Mitya Sirenef
On 12/17/2012 12:00 AM, boB Stepp wrote: On Sun, Dec 16, 2012 at 10:41 PM, Mitya Sirenef wrote: > >> What would you want to happen for int("10.5")? If 10.0 was accepted, >> it would be consistent to accept 10.5, too. > > I was expecting int("10.5") to return 10 . I just want to note that thi

Re: [Tutor] Limitation of int() in converting strings

2012-12-16 Thread boB Stepp
On Sun, Dec 16, 2012 at 10:41 PM, Mitya Sirenef wrote: > What would you want to happen for int("10.5")? If 10.0 was accepted, > it would be consistent to accept 10.5, too. I was expecting int("10.5") to return 10 . > The issue, I think, is that a simple operation should not go too far > beyond

Re: [Tutor] Get the structure values from a c file

2012-12-16 Thread Dave Angel
On 12/16/2012 10:12 PM, Marefe Serentas wrote: > Hi, I need help. > > I want to create a python script that will store the value of the > structure /MainStruct/ from the c file. > Suppose my c file looks like this: > -- > #define max (3) > > t

Re: [Tutor] Limitation of int() in converting strings

2012-12-16 Thread Mitya Sirenef
On 12/16/2012 11:19 PM, boB Stepp wrote: int('10.0') > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '10.0' int("10") > 10 > > It is apparent that int() does not like strings with floating-point > formats. None of my books (a

[Tutor] Limitation of int() in converting strings

2012-12-16 Thread boB Stepp
>>> int('10.0') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '10.0' >>> int("10") 10 It is apparent that int() does not like strings with floating-point formats. None of my books (as far as my flipping can tell) or the below built-in

[Tutor] Get the structure values from a c file

2012-12-16 Thread Marefe Serentas
Hi, I need help. I want to create a python script that will store the value of the structure /MainStruct/ from the c file. Suppose my c file looks like this: -- #define max (3) typedef struct A { int a; char b; }A; typedef struct

Re: [Tutor] Trailing spaces affect output in a way I don't understand.

2012-12-16 Thread eryksun
On Sat, Dec 15, 2012 at 11:55 PM, boB Stepp wrote: > On Sat, Dec 15, 2012 at 10:43 PM, Steven D'Aprano wrote: > >> Two solutions are: >> >> * Add a space to the end of the backslashes. The space is invisible, and >> some editors may strip it out, so this is a fragile solution. > > In my efforts t