Steven D'Aprano wrote:
Big Oh notation is good for estimating asymptotic behaviour, which means it
is good for predicting how an algorithm will scale as the size of the input
increases. It is useless for predicting how fast that algorithm will run,
since the actual speed depends on those constan
Chris Rebert wrote:
> Obviously that equivalence is true, but in this case I'm emphasizing
> that it's even worse than that when constant factors are taken into
> account. Big-O is nice in the abstract, but in the real-world those
> constant factors can matter.
>
> In pure big-O, it is indeed O(M
Thank you very much for all your replies. I actually used the while
loop as the data is not large. But I was looking for a simpler, built
in command, something like L.remove('a', all) or L.removeall('a').
Python has re.findall function, but why not removeall, so users have
to make up long lines of
On Fri, Feb 27, 2009 at 5:10 AM, Steve Holden wrote:
> Chris Rebert wrote:
>> On Thu, Feb 26, 2009 at 10:26 PM, odeits wrote:
> [...]
>>> while 'a' in L:
>>> L.remove('a')
>>>
>>> not the most efficient but it works
>>
>> "Not the most efficient"; it's terribly inefficient! It's 2*O(M*N) [M
>>
Chris Rebert wrote:
> On Thu, Feb 26, 2009 at 10:26 PM, odeits wrote:
[...]
>> while 'a' in L:
>> L.remove('a')
>>
>> not the most efficient but it works
>
> "Not the most efficient"; it's terribly inefficient! It's 2*O(M*N) [M
> = number of 'a's in L], versus just N. And that's not even accoun
On Thu, Feb 26, 2009 at 10:26 PM, odeits wrote:
> On Feb 26, 3:05 am, Clarendon wrote:
>> Hi. This must be a simple command but I just can't find it in the
>> Phthon manual. How do I delete all items with a certain condition from
>> a list? For instance:
>>
>> L=['a', 'b', 'c', 'a']
>>
>> I want
On Feb 26, 3:05 am, Clarendon wrote:
> Hi. This must be a simple command but I just can't find it in the
> Phthon manual. How do I delete all items with a certain condition from
> a list? For instance:
>
> L=['a', 'b', 'c', 'a']
>
> I want to delete all 'a's from the list.
> But if L.remove('a') o
On Thu, Feb 26, 2009 at 4:37 PM, Gabriel Genellina
wrote:
> En Thu, 26 Feb 2009 22:18:18 -0200, Chris Rebert
> escribió:
>>
>> On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam
>> wrote:
>>>
>>> On 2009-02-26, Clarendon wrote:
Hi. This must be a simple command but I just can't find it in
En Thu, 26 Feb 2009 22:18:18 -0200, Chris Rebert
escribió:
On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam
wrote:
On 2009-02-26, Clarendon wrote:
Hi. This must be a simple command but I just can't find it in the
Phthon manual. How do I delete all items with a certain condition from
a list? F
Peter Billam wrote:
> On 2009-02-26, Clarendon wrote:
>> Hi. This must be a simple command but I just can't find it in the
>> Phthon manual. How do I delete all items with a certain condition from
>> a list? For instance: > L=['a', 'b', 'c', 'a']
>> I want to delete all 'a's from the list. > But
On 2009-02-27, Chris Rebert wrote:
> On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam wrote:
>> On 2009-02-26, Clarendon wrote:
>>> How do you delete all 'a's?
>>
>> L2 = list(set(L))
>> works for me...
>
> A. That doesn't by itself remove all the 'a's, although it does
> remove all but 1 'a'
> B.
En Thu, 26 Feb 2009 22:08:26 -0200, Peter Billam
escribió:
On 2009-02-26, Clarendon wrote:
Hi. This must be a simple command but I just can't find it in the
Phthon manual. How do I delete all items with a certain condition from
a list? For instance: > L=['a', 'b', 'c', 'a']
I want to delete
On Thu, Feb 26, 2009 at 4:08 PM, Peter Billam wrote:
> On 2009-02-26, Clarendon wrote:
>> Hi. This must be a simple command but I just can't find it in the
>> Phthon manual. How do I delete all items with a certain condition from
>> a list? For instance: > L=['a', 'b', 'c', 'a']
>> I want to dele
On 2009-02-26, Clarendon wrote:
> Hi. This must be a simple command but I just can't find it in the
> Phthon manual. How do I delete all items with a certain condition from
> a list? For instance: > L=['a', 'b', 'c', 'a']
> I want to delete all 'a's from the list. > But if L.remove('a')
> only de
Terry Reedy wrote:
> Steve Holden wrote:
>> Terry Reedy wrote:
>>> Gabriel Genellina wrote:
>>>
> L = filter('a'.__ne__,L)
And this is probably the fastest. But not all types define __ne__
>>> In Py3, all classes inherit .__ne__ from 'object'.
>>>
>> Isn't that inherited method just an id
Steve Holden wrote:
Terry Reedy wrote:
Gabriel Genellina wrote:
L = filter('a'.__ne__,L)
And this is probably the fastest. But not all types define __ne__
In Py3, all classes inherit .__ne__ from 'object'.
Isn't that inherited method just an identity comparison?
Yes. And so is, by defau
Terry Reedy wrote:
> Gabriel Genellina wrote:
>
>>
>>> L = filter('a'.__ne__,L)
>>
>> And this is probably the fastest. But not all types define __ne__
>
> In Py3, all classes inherit .__ne__ from 'object'.
>
Isn't that inherited method just an identity comparison?
However in this particular c
Gabriel Genellina wrote:
L = filter('a'.__ne__,L)
And this is probably the fastest. But not all types define __ne__
In Py3, all classes inherit .__ne__ from 'object'.
--
http://mail.python.org/mailman/listinfo/python-list
>>
>> > L = filter('a'.__ne__,L)
>>
>> And this is probably the fastest. But not all types define
>> __ne__ so a
>> more generic answer would be:
>>
>> from functools import partial
>> from operator import ne
>> L = filter(partial(ne, 'a'), L)
>>
And don't forget this "traditio
En Thu, 26 Feb 2009 11:00:30 -0200, Boris Borcic
escribió:
Chris Rebert wrote:
On Thu, Feb 26, 2009 at 3:05 AM, Clarendon wrote:
...
L=['a', 'b', 'c', 'a']
I want to delete all 'a's from the list.
But if L.remove('a') only deletes the first 'a'.
How do you delete all 'a's?
There are s
Chris Rebert wrote:
On Thu, Feb 26, 2009 at 3:05 AM, Clarendon wrote:
...
L=['a', 'b', 'c', 'a']
I want to delete all 'a's from the list.
But if L.remove('a') only deletes the first 'a'.
How do you delete all 'a's?
There are several ways. I'd go with a list comprehension:
and for a coupl
Clarendon a écrit :
Hi. This must be a simple command but I just can't find it in the
Phthon manual. How do I delete all items with a certain condition from
a list? For instance:
L=['a', 'b', 'c', 'a']
I want to delete all 'a's from the list.
But if L.remove('a') only deletes the first 'a'.
Ho
On Thu, Feb 26, 2009 at 3:05 AM, Clarendon wrote:
> Hi. This must be a simple command but I just can't find it in the
> Phthon manual. How do I delete all items with a certain condition from
> a list? For instance:
>
> L=['a', 'b', 'c', 'a']
>
> I want to delete all 'a's from the list.
> But if L.
23 matches
Mail list logo