Re: [Tutor] What is the difference between checking false?

2013-06-16 Thread Chris “Kwpolska” Warrick
On Sun, Jun 16, 2013 at 7:52 AM, Jim Mooney wrote: > On 15 June 2013 22:32, Steven D'Aprano wrote: >> http://mail.python.org/pipermail/python-list/2013-June/649710.html > > A succinct list - worth putting in my Keep file ;') > > - > Jim > After indictment the bacon smuggler was put on the no-fry

Re: [Tutor] What is the difference between checking false?

2013-06-16 Thread eryksun
On Sat, Jun 15, 2013 at 11:15 PM, Jim Mooney wrote: > > ## Comparing different types for equality always fails: > > if '5' != 5: > print('oops') It depends on the __eq__ and __ne__ methods defined by the types. int and str have their own implementations of "rich comparisons". But that's a sub

Re: [Tutor] What is the difference between checking false?

2013-06-16 Thread eryksun
On Sat, Jun 15, 2013 at 11:53 PM, Jim Mooney wrote: > > class NobodyHome: pass > x = NobodyHome() > print(not x) # Result is False when I thought this would be True. Quote: >> If neither __bool__ nor __len__ is defined, the object defaults to being >> truthy: >> >> >>> not not object() >>

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Jim Mooney
On 15 June 2013 22:32, Steven D'Aprano wrote: > http://mail.python.org/pipermail/python-list/2013-June/649710.html A succinct list - worth putting in my Keep file ;') - Jim After indictment the bacon smuggler was put on the no-fry list ___ Tutor mailli

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Steven D'Aprano
On 16/06/13 12:31, Joel Goldstick wrote: On Sat, Jun 15, 2013 at 10:21 PM, Jim Mooney wrote: On 15 June 2013 19:03, Dave Angel wrote: Why such a convoluted way of expressing yourself? I was demonstrating the parallelism, but let's just take one so I can unbefuddle meself ;') *** Python 3.3

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Steven D'Aprano
On 16/06/13 13:15, Jim Mooney wrote: ## Comparing different types for equality always fails: if '5' != 5: print('oops') Not always. Counter-examples are most obvious when it comes to numbers: py> from decimal import Decimal py> from fractions import Fraction py> Fraction(1, 2) == Decima

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Steven D'Aprano
On 16/06/13 11:30, Jim Mooney wrote: ##This is puzzling me. If I check the equality of 0, None, empty string, and empty list with False, ##only zero satisfies the equality. But if I use them in a not statement, they all turn out False. ##What gives? That's because the tests do different things

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Jim Mooney
On 15 June 2013 21:41, Dave Angel wrote: class NobodyHome: > ... def __bool__(self): > ... return False #normally, you'd be testing some attribute to > decide this > > ... x = NobodyHome() not x > True > That's a breath of fresh air - talk about freedom ;') Makes me

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Dave Angel
On 06/15/2013 11:53 PM, Jim Mooney wrote: On 15 June 2013 20:48, Joel Goldstick wrote: One and zero for True and False may seem not quite right today, I still think they should be taken out and shot ;') But my simplification plan failed. Equality always fails for different types, and 'not i

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Jim Mooney
On 15 June 2013 20:48, Joel Goldstick wrote: > > One and zero for True and False may seem not quite right today, but digital > computers are based on the fact that circuits can be built that have two > states -- on/off or true/false, or 1/0. But then, if we're going down to the gate level, why no

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Jim Mooney
On 15 June 2013 20:48, Joel Goldstick wrote: > One and zero for True and False may seem not quite right today, I still think they should be taken out and shot ;') But my simplification plan failed. Equality always fails for different types, and 'not in front of None or any empty object such as

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Joel Goldstick
On Sat, Jun 15, 2013 at 11:15 PM, Jim Mooney wrote: > On 15 June 2013 19:45, eryksun wrote: > > On Sat, Jun 15, 2013 at 10:23 PM, eryksun wrote: > >> This function is hard coded for the singletons True, > >> False, and None -- and otherwise uses either __bool__ > >> (tp_as_number->nb_bool) or __

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Jim Mooney
On 15 June 2013 19:45, eryksun wrote: > On Sat, Jun 15, 2013 at 10:23 PM, eryksun wrote: >> This function is hard coded for the singletons True, >> False, and None -- and otherwise uses either __bool__ >> (tp_as_number->nb_bool) or __len__ (tp_as_mapping->mp_length or >> tp_as_sequence->sq_length

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread eryksun
On Sat, Jun 15, 2013 at 10:23 PM, eryksun wrote: > This function is hard coded for the singletons True, > False, and None -- and otherwise uses either __bool__ > (tp_as_number->nb_bool) or __len__ (tp_as_mapping->mp_length or > tp_as_sequence->sq_length). A length of 0 is falsey. I forgot to add

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Jim Mooney
On 15 June 2013 19:28, Dave Angel wrote: > If you want to compare a non-boolean to False or True, expect it'll always > be false. They are different types. (except for the int historical > nonsense I mentioned earlier). Ah, that clarifies it - type differences - something I can look out for -

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Joel Goldstick
On Sat, Jun 15, 2013 at 10:21 PM, Jim Mooney wrote: > On 15 June 2013 19:03, Dave Angel wrote: > > Why such a convoluted way of expressing yourself? > > I was demonstrating the parallelism, but let's just take one so I can > unbefuddle meself ;') > > *** Python 3.3.2 32 bit (Intel)] on win32. ***

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Dave Angel
On 06/15/2013 10:21 PM, Jim Mooney wrote: On 15 June 2013 19:03, Dave Angel wrote: Why such a convoluted way of expressing yourself? I was demonstrating the parallelism, but let's just take one so I can unbefuddle meself ;') *** Python 3.3.2 32 bit (Intel)] on win32. *** '' == False False

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread eryksun
On Sat, Jun 15, 2013 at 9:30 PM, Jim Mooney wrote: > This is puzzling me. If I check the equality of 0, None, empty > string, and empty list with False, only zero satisfies the equality. > But if I use them in a not statement, they all turn out False. > What gives? > > #Using C:\Python33\python.ex

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Jim Mooney
On 15 June 2013 19:03, Dave Angel wrote: > Why such a convoluted way of expressing yourself? I was demonstrating the parallelism, but let's just take one so I can unbefuddle meself ;') *** Python 3.3.2 32 bit (Intel)] on win32. *** >>> '' == False False >>> not '' True >>> Why the difference he

Re: [Tutor] What is the difference between checking false?

2013-06-15 Thread Dave Angel
On 06/15/2013 09:30 PM, Jim Mooney wrote: ##This is puzzling me. If I check the equality of 0, None, empty string, and empty list with False, ##only zero satisfies the equality. But if I use them in a not statement, they all turn out False. ##What gives? #Using C:\Python33\python.exe on Win 7 in

[Tutor] What is the difference between checking false?

2013-06-15 Thread Jim Mooney
##This is puzzling me. If I check the equality of 0, None, empty string, and empty list with False, ##only zero satisfies the equality. But if I use them in a not statement, they all turn out False. ##What gives? #Using C:\Python33\python.exe on Win 7 in c:\python33\jimprogs print('Zero is equal

Re: [Tutor] What is the difference between the now depreciated threading module and the multiprocessing module

2011-10-04 Thread Prasad, Ramit
>I was wondering if anyone could tell me why threading was depreciated; and >give me a use case for the >multiprocessing : Queue function in python 2.7. Threading was *not* deprecated Python 2.x or 3.x http://docs.python.org/dev/py3k/library/threading.html?highlight=threading#threading http://

[Tutor] What is the difference between the now depreciated threading module and the multiprocessing module

2011-10-04 Thread Earnest Gildon
I was wondering if anyone could tell me why threading was depreciated; and give me a use case for the multiprocessing : Queue function in python 2.7. Thanks, -earnest ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options

Re: [Tutor] WHAT IS THE DIFFERENCE BETWEEN FILTER AND REDUCE FUNCTION

2008-09-24 Thread Steve Willoughby
Warning: this is going to look *a lot* better if you view it in a fixed-width font so things line up properly. Both functions apply a function to a list of values, but they do so in different ways. filter() applies a function to each element of a list in turn, returning a new list containing

[Tutor] WHAT IS THE DIFFERENCE BETWEEN FILTER AND REDUCE FUNCTION

2008-09-23 Thread sudhir . kumar
___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] what is the difference

2007-12-13 Thread Alan Gauld
"Tiger12506" <[EMAIL PROTECTED]> wrote >>> I can not see the difference but the second one acts differently >>> in >>> my code. >> >> The first has no else clause so the second assignment always >> happens. >> >> Alan G. > > No it doesn't. The return statement does not allow the second > assig

Re: [Tutor] what is the difference

2007-12-13 Thread Tiger12506
> "johnf" <[EMAIL PROTECTED]> wrote > >> if self._inFlush: >> return >> self._inFlush = True >> >> >> AND >> >> if not self._inFlush: >> ... >> self._inFlush = True >> else: >> return >> >> I can not see the difference but the second one acts differently in >> my code. > > T

Re: [Tutor] what is the difference

2007-12-13 Thread Alan Gauld
"johnf" <[EMAIL PROTECTED]> wrote > if self._inFlush: > return > self._inFlush = True > > > AND > > if not self._inFlush: > ... > self._inFlush = True > else: > return > > I can not see the difference but the second one acts differently in > my code. The first has no els

[Tutor] what is the difference

2007-12-13 Thread Michael H. Goldwasser
Hi John, It depends upon whether the "..." code fragment is affected in any way by the value of self._inFlush. The first code sample you offer should be identical to the following. if not self._inFlush: self._inFlush = True# reset this before the ... ... else:

[Tutor] what is the difference

2007-12-13 Thread johnf
if self._inFlush: return self._inFlush = True AND if not self._inFlush: ... self._inFlush = True else: return I can not see the difference but the second one acts differently in my code. -- John Fabiani ___ Tutor m