That might also work:
new_list = [i for i in the_list if i not in targets]
# given you have no special requirements for the selection
# out of 'targets'
-Sivan
On Wed, Dec 9, 2015 at 12:58 AM, Thomas 'PointedEars' Lahn <
pointede...@web.de> wrote:
> Mark Lawrence wrote:
>
> > On 03/12/2015
On Wednesday 09 December 2015 09:58, Thomas 'PointedEars' Lahn wrote:
> Mark Lawrence wrote:
>
>> On 03/12/2015 01:15, c.bu...@posteo.jp wrote:
>>> I would like to know how this could be done more elegant/pythonic.
>>>
>>> I have a big list (over 10.000 items) with strings (each 100 to 300
>>>
Mark Lawrence wrote:
> On 03/12/2015 01:15, c.bu...@posteo.jp wrote:
>> I would like to know how this could be done more elegant/pythonic.
>>
>> I have a big list (over 10.000 items) with strings (each 100 to 300
>> chars long) and want to filter them.
>>
>> list = .
>> […]
>
> targets =
On Thu, 3 Dec 2015 10:27:19 +0100, wrote:
[snip]
> I often saw constructions like this
> x for x in y if ...
> But I don't understand that combination of the Python keywords (for,
> in, if) I allready know. It is to complex to imagine what there really
> happen.
Don't give
On Thu, Dec 3, 2015 at 8:27 PM, wrote:
> Thank you for your suggestion. This will help a lot.
>
> On 2015-12-03 08:32 Jussi Piitulainen wrote:
>> list = [ item for item in list
>> if ( 'Banana' not in item and
>> 'Car' not in item
On 03/12/15 02:15, c.bu...@posteo.jp wrote:
I would like to know how this could be done more elegant/pythonic.
I have a big list (over 10.000 items) with strings (each 100 to 300
chars long) and want to filter them.
list = .
for item in list[:]:
if 'Banana' in item:
writes:
> Thank you for your suggestion. This will help a lot.
>
> On 2015-12-03 08:32 Jussi Piitulainen wrote:
>> list = [ item for item in list
>> if ( 'Banana' not in item and
>> 'Car' not in item ) ]
>
> I often saw constructions like this
> x for
On 03/12/2015 01:15, c.bu...@posteo.jp wrote:
I would like to know how this could be done more elegant/pythonic.
I have a big list (over 10.000 items) with strings (each 100 to 300
chars long) and want to filter them.
list = .
for item in list[:]:
if 'Banana' in item:
On 03.12.2015 10:27, c.bu...@posteo.jp wrote:
>
> I often saw constructions like this
>x for x in y if ...
> But I don't understand that combination of the Python keywords (for,
> in, if) I allready know. It is to complex to imagine what there really
> happen.
>
> I understand this
>for x
In a message of Thu, 03 Dec 2015 10:27:19 +0100, c.bu...@posteo.jp writes:
>Thank you for your suggestion. This will help a lot.
>
>On 2015-12-03 08:32 Jussi Piitulainen wrote:
>> list = [ item for item in list
>> if ( 'Banana' not in item and
>>
On 12/03/2015 10:27 AM, c.bu...@posteo.jp wrote:
I often saw constructions like this
x for x in y if ...
But I don't understand that combination of the Python keywords (for,
in, if) I allready know. It is to complex to imagine what there really
happen.
I understand this
for x in y:
Thank you for your suggestion. This will help a lot.
On 2015-12-03 08:32 Jussi Piitulainen wrote:
> list = [ item for item in list
> if ( 'Banana' not in item and
> 'Car' not in item ) ]
I often saw constructions like this
x for x in y if ...
But
Laura Creighton wrote:
> In a message of Thu, 03 Dec 2015 10:27:19 +0100, c.bu...@posteo.jp writes:
>>Thank you for your suggestion. This will help a lot.
>>
>>On 2015-12-03 08:32 Jussi Piitulainen wrote:
>>> list = [ item for item in list
>>> if ( 'Banana' not in
On Thu, 03 Dec 2015 08:32:49 +0200, Jussi Piitulainen wrote:
> def isbad(item):
> return ( 'Banana' in item or
> 'Car' in item )
>
> def isgood(item)
> return not isbad(item)
badthings = [ 'Banana', 'Car', ]
def isgood(item)
for thing in badthings:
if
Denis McMahon writes:
> On Thu, 03 Dec 2015 08:32:49 +0200, Jussi Piitulainen wrote:
>
>> def isbad(item):
>> return ( 'Banana' in item or
>> 'Car' in item )
>>
>> def isgood(item)
>> return not isbad(item)
>
> badthings = [ 'Banana', 'Car', ]
>
> def isgood(item)
>
On 12/3/2015 7:28 AM, Mark Lawrence wrote:
On 03/12/2015 01:15, c.bu...@posteo.jp wrote:
I would like to know how this could be done more elegant/pythonic.
I have a big list (over 10.000 items) with strings (each 100 to 300
chars long) and want to filter them.
list = .
for item in
writes:
> I would like to know how this could be done more elegant/pythonic.
>
> I have a big list (over 10.000 items) with strings (each 100 to 300
> chars long) and want to filter them.
>
> list = .
>
> for item in list[:]:
> if 'Banana' in item:
>
I would like to know how this could be done more elegant/pythonic.
I have a big list (over 10.000 items) with strings (each 100 to 300
chars long) and want to filter them.
list = .
for item in list[:]:
if 'Banana' in item:
list.remove(item)
if 'Car' in item:
list.remove(item)
18 matches
Mail list logo