Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-16 Thread Carl Banks
Neil Cerutti wrote: > On 2007-01-16, Ron Adam <[EMAIL PROTECTED]> wrote: > > I have to admit that part of why assert seems wrong to me is > > the meaning of the word implies something you shouldn't be able > > to ignore. While warnings seem like something that can be > > disregarded. > > Experien

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-16 Thread Ron Adam
Neil Cerutti wrote: > On 2007-01-16, Ron Adam <[EMAIL PROTECTED]> wrote: >> I have to admit that part of why assert seems wrong to me is >> the meaning of the word implies something you shouldn't be able >> to ignore. While warnings seem like something that can be >> disregarded. > > Experi

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-16 Thread Neil Cerutti
On 2007-01-16, Ron Adam <[EMAIL PROTECTED]> wrote: > I have to admit that part of why assert seems wrong to me is > the meaning of the word implies something you shouldn't be able > to ignore. While warnings seem like something that can be > disregarded. Experienced C coders expect assert to beha

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-16 Thread Ron Adam
Carl Banks wrote: > Ron Adam wrote: >> There have been times where I would like assert to be a little more assertive >> than it is. :-) >> >> ie.. not being able to turn them off with the -0/-00 switches, and having >> them >> generate a more verbose traceback. > > Personally, I'd rather see it

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Carl Banks
Ron Adam wrote: > There have been times where I would like assert to be a little more assertive > than it is. :-) > > ie.. not being able to turn them off with the -0/-00 switches, and having them > generate a more verbose traceback. Personally, I'd rather see it get less assertive, i.e., having

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Ron Adam
Steven D'Aprano wrote: > On Mon, 15 Jan 2007 21:01:35 -0600, Ron Adam wrote: > > >> There have been times where I would like assert to be a little more >> assertive >> than it is. :-) >> >> ie.. not being able to turn them off with the -0/-00 switches, and having >> them >> generate a more v

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Steven D'Aprano
On Mon, 15 Jan 2007 21:01:35 -0600, Ron Adam wrote: > There have been times where I would like assert to be a little more assertive > than it is. :-) > > ie.. not being able to turn them off with the -0/-00 switches, and having > them > generate a more verbose traceback. If you want somethi

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Calvin Spealman
On 1/15/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 15 Jan 2007 17:50:56 -0500, Calvin Spealman wrote: > > > assert foo(0x10) == 0 # Assertions are much better tests than prints :-) > > I dispute that assertion (pun intended). Hah! > Firstly, print statements work even if you pass t

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Calvin Spealman
On 1/15/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 15 Jan 2007 21:38:42 -0500, Calvin Spealman wrote: > > > On 1/15/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > >> On Mon, 15 Jan 2007 17:50:56 -0500, Calvin Spealman wrote: > >> > >> > assert foo(0x10) == 0 # Assertions are much b

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Steven D'Aprano
On Mon, 15 Jan 2007 21:38:42 -0500, Calvin Spealman wrote: > On 1/15/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> On Mon, 15 Jan 2007 17:50:56 -0500, Calvin Spealman wrote: >> >> > assert foo(0x10) == 0 # Assertions are much better tests than prints :-) >> >> I dispute that assertion (pun in

Re: assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Ron Adam
Calvin Spealman wrote: > On 1/15/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> On Mon, 15 Jan 2007 17:50:56 -0500, Calvin Spealman wrote: >> >>> assert foo(0x10) == 0 # Assertions are much better tests than prints :-) >> I dispute that assertion (pun intended). > > Hah! > >> Firstly, print s

assert versus print [was Re: The curious behavior of integer objects]

2007-01-15 Thread Steven D'Aprano
On Mon, 15 Jan 2007 17:50:56 -0500, Calvin Spealman wrote: > assert foo(0x10) == 0 # Assertions are much better tests than prints :-) I dispute that assertion (pun intended). Firstly, print statements work even if you pass the -O (optimize) flag to Python. Your asserts don't. Secondly, a bare

Re: The curious behavior of integer objects

2007-01-15 Thread Gabriel Genellina
At Monday 15/1/2007 19:28, Jim B. Wilson wrote: Am I nuts? Or only profoundly confused? I expected the this little script to print "0": class foo(int): def __init__(self, value): self = value & 0xF print foo(0x10) Instead, it prints "16" (at least on python 2.4.4 (Linux) and 2.5 (Wine).

Re: The curious behavior of integer objects

2007-01-15 Thread Robert Kern
Jim B. Wilson wrote: > Am I nuts? Or only profoundly confused? I expected the this little script > to print "0": > > class foo(int): > def __init__(self, value): > self = value & 0xF That statement only rebinds the local name self to something else. It does not modify the object at all or

Re: The curious behavior of integer objects

2007-01-15 Thread Calvin Spealman
As it turns out, this has little to do with integers and the operations you are trying to do on them. I'll explain in more detail. Integers are immutable, which you may already know. This presents a problem with subclassing them and using the usual special method __init__, because the int object h

The curious behavior of integer objects

2007-01-15 Thread Jim B. Wilson
Am I nuts? Or only profoundly confused? I expected the this little script to print "0": class foo(int): def __init__(self, value): self = value & 0xF print foo(0x10) Instead, it prints "16" (at least on python 2.4.4 (Linux) and 2.5 (Wine). Jim Wilson GNV, FL -- http://mail.python.org/ma