On 7/12/2017 7:35 AM, Rhodri James wrote:
On 12/07/17 03:29, Stefan Ram wrote:
Grant Edwards writes:
False is required to be a singleton.
»singleton« usually means »the sole object of its class«.
»Ensure a class only has one instance, and provide a
global point of access to
On 12/07/17 03:29, Stefan Ram wrote:
Grant Edwards writes:
False is required to be a singleton.
»singleton« usually means »the sole object of its class«.
»Ensure a class only has one instance, and provide a
global point of access to it.« - Gamma et al.
We are using the ter
On Tue, 11 Jul 2017 11:16 pm, Albert-Jan Roskam wrote:
> >>> False == 0
> True
> >>> False is 0
> False
>
>
> => Just wondering: Is this 'is' test depending on an implementation detail
> of cPython (small ints, I forgot how small 0-255 maybe, are singletons)?
No. But the test 0 is 0 will b
On 2017-07-11, Albert-Jan Roskam wrote:
> From: Python-list on
> behalf of Dan Sommers
> Sent: Friday, July 7, 2017 2:46 AM
> To: python-list@python.org
> Subject: Re: Test 0 and false since false is 0
>
> On Thu, 06 Jul 2017 19:29:00 -0700, Sayth Renshaw wrote:
On 11/07/17 14:16, Albert-Jan Roskam wrote:
From: Python-list on behalf
of Dan Sommers
Sent: Friday, July 7, 2017 2:46 AM
To: python-list@python.org
Subject: Re: Test 0 and false since false is 0
On Thu, 06 Jul 2017 19:29:00 -0700, Sayth Renshaw wrote:
I have tried or conditions of v
From: Python-list on
behalf of Dan Sommers
Sent: Friday, July 7, 2017 2:46 AM
To: python-list@python.org
Subject: Re: Test 0 and false since false is 0
On Thu, 06 Jul 2017 19:29:00 -0700, Sayth Renshaw wrote:
> I have tried or conditions of v == False etc but then the 0's being
On 2017-07-09, Paul D. DeRocco wrote:
>> From: Sayth Renshaw
>>
>> I have been reading this solution
>> > >>> after = sorted(before, key=lambda x: x == 0 and type(x) == int)
>>
>> it is really good, however I don't understand it enough to
>> reimplement something like that myself yet.
>>
>> T
> From: Sayth Renshaw
>
> I have been reading this solution
> > >>> after = sorted(before, key=lambda x: x == 0 and type(x) == int)
>
> it is really good, however I don't understand it enough to
> reimplement something like that myself yet.
>
> Though I can that lambda tests for 0 that is equa
> Another option is to test for type(value) == int:
>
> >>> before = ["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,
> {},0,0,9]
> >>> wanted = ["a","b",None,"c","d",1,False,1,3,[],1,9,
> {},9,0,0,0,0,0,0,0,0,0,0]
> >>> after = sorted(before, key=lambda x: x == 0 and type(x) == int)
> >
Nathan Ernst wrote:
> On Fri, Jul 7, 2017 at 2:04 AM, Peter Otten <__pete...@web.de> wrote:
>> >>> sorted([0.0, 0, False, [], "x"], key=lambda x: x == 0 and type(x) ==
>> int)
>> [0.0, False, [], 'x', 0]
> You'd be better off using the builtin "isinstance" function, e.g.:
> isinstance(x, int). T
You'd be better off using the builtin "isinstance" function, e.g.:
isinstance(x, int). This also has the added benefit of working nicely with
inheritance (isinstance returns true if the actual type is derived from the
classinfo passed as the second argument). See
https://docs.python.org/3/library/f
On 2017-07-07, Stefan Ram wrote:
> Sayth Renshaw writes:
>>I have tried or conditions of v == False etc but then the 0's
>>being false also aren't moved. How can you check this at
>>once?
>
> »The Boolean type is a subtype of the integer type, and
> Boolean values behave like the valu
you can use the "is" for identity test.
l1 = [v for v in array if not v is 0]
l2 = [v for v in array if v is 0]
On Jul 6, 2017, at 10:31 PM, Sayth Renshaw
mailto:flebber.c...@gmail.com>> wrote:
I was trying to solve a problem and cannot determine how to filter 0's but not
false.
Given a list l
> From: Dan Sommers
>
> > On Thu, 06 Jul 2017 19:29:00 -0700, Sayth Renshaw wrote:
> >
> > I have tried or conditions of v == False etc but then the 0's being
> > false also aren't moved. How can you check this at once?
>
> Maybe this will help:
>
> Python 3.5.3+ (default, Jun 7 2017, 23:2
Sayth Renshaw wrote:
> I was trying to solve a problem and cannot determine how to filter 0's but
> not false.
>
> Given a list like this
> ["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,{},0,0,9]
>
> I want to be able to return this list
> ["a","b",None,"c","d",1,False,1,3,[],1,9,{},9
On Thursday, July 6, 2017 at 9:57:43 PM UTC-5, Skip Montanaro wrote:
> I was trying to solve a problem and cannot determine how to filter 0's but
> not false.
>
>
> I'm typing on my phone so can't paste a session [...]
I have not tried any for myself, but there are a few Python
installations avail
On Thursday, July 6, 2017 at 10:00:36 PM UTC-5, Sayth Renshaw wrote:
> Is there an "is not" method that's not != so I can check is not false.
Maybe. Or maybe /not/. :-P"
One way to find out would be to fire up your python
interpretor, and do some interactive testing. Here, allow me
to cinge my ey
On Friday, 7 July 2017 12:46:51 UTC+10, Rick Johnson wrote:
> On Thursday, July 6, 2017 at 9:29:29 PM UTC-5, Sayth Renshaw wrote:
> > I was trying to solve a problem and cannot determine how to filter 0's but
> > not false.
> >
> > Given a list like this
> > ["a",0,0,"b",None,"c","d",0,1,False,0
On Fri, 07 Jul 2017 02:48:45 +, Stefan Ram wrote:
def isfalse( x ):
> ... return x == 0 and str( type( x )) == ""
> ...
>
Don't depend on string representations of objects, unless you know what
you're doing. Do this instead:
def isfalse(x):
return x == 0 and type(x) is b
I was trying to solve a problem and cannot determine how to filter 0's but
not false.
I'm typing on my phone so can't paste a session, so I will attempt to apply
the Socratic method, and ask: Do you understand why your attempts have
failed so far? In what way are False and 0 the same? In what res
On Thu, 06 Jul 2017 19:29:00 -0700, Sayth Renshaw wrote:
> I have tried or conditions of v == False etc but then the 0's being
> false also aren't moved. How can you check this at once?
Maybe this will help:
Python 3.5.3+ (default, Jun 7 2017, 23:23:48)
[GCC 6.3.0 20170516] on linux
On Thursday, July 6, 2017 at 9:29:29 PM UTC-5, Sayth Renshaw wrote:
> I was trying to solve a problem and cannot determine how to filter 0's but
> not false.
>
> Given a list like this
> ["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,{},0,0,9]
>
> I want to be able to return this list
22 matches
Mail list logo