Short-circuit Logic

2013-05-26 Thread Ahmed Abdulshafy
Hi, I'm having a hard time wrapping my head around short-circuit logic that's used by Python, coming from a C/C++ background; so I don't understand why the following condition is written this way!> if not allow_zero and abs(x) < sys.float_info.epsilon: print("zero is not all

Re: Short-circuit Logic

2013-05-27 Thread Ahmed Abdulshafy
On Sunday, May 26, 2013 1:11:56 PM UTC+2, Ahmed Abdulshafy wrote: > Hi, > > I'm having a hard time wrapping my head around short-circuit logic that's > used by Python, coming from a C/C++ background; so I don't understand why the > following condition is written

Re: Short-circuit Logic

2013-05-27 Thread Ahmed Abdulshafy
On Sunday, May 26, 2013 2:13:47 PM UTC+2, Steven D'Aprano wrote: > On Sun, 26 May 2013 04:11:56 -0700, Ahmed Abdulshafy wrote: > > > > > Hi, > > > I'm having a hard time wrapping my head around short-circuit logic > > > that's used by

Re: Short-circuit Logic

2013-05-28 Thread Ahmed Abdulshafy
On Tuesday, May 28, 2013 2:10:05 AM UTC+2, Nobody wrote: > On Mon, 27 May 2013 13:11:28 -0700, Ahmed Abdulshafy wrote: > > > > > On Sunday, May 26, 2013 2:13:47 PM UTC+2, Steven D'Aprano wrote: > > > > > >> What the above actually tests for is wheth

Re: Short-circuit Logic

2013-05-29 Thread Ahmed Abdulshafy
On Tuesday, May 28, 2013 3:48:17 PM UTC+2, Steven D'Aprano wrote: > On Mon, 27 May 2013 13:11:28 -0700, Ahmed Abdulshafy wrote: > > > > > That may be true for integers, but for floats, testing for equality is > > > not always precise > > > > Incor

Default Value

2013-06-19 Thread Ahmed Abdulshafy
I'm reading the Python.org tutorial right now, and I found this part rather strange and incomprehensible to me> Important warning: The default value is evaluated only once. This makes a difference when the default is a mutable object such as a list, dictionary, or instances of most classes def