Sion Arrowsmith wrote:
> Robert Latest <[EMAIL PROTECTED]> wrote:
>> BTW, where can I find all methods of the built-in types?
>>Section 3.6 only talks about strings and mentions the list append() method
>>only in an example. Am I too stupid to read the manual, or is this an
>>omission?
>
> 3.6
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
>
> > Using keywords[:] stops the creation of another temporary list.
>
> in CPython, "list[:] = iter" actually creates a temporary list object on
> the inside, in case "iter" isn't already a list or a tuple.
>
> (see the imp
Robert Latest <[EMAIL PROTECTED]> wrote:
> BTW, where can I find all methods of the built-in types?
>Section 3.6 only talks about strings and mentions the list append() method
>only in an example. Am I too stupid to read the manual, or is this an
>omission?
3.6 talks about features common to a
Nick Craig-Wood wrote:
> Using keywords[:] stops the creation of another temporary list.
in CPython, "list[:] = iter" actually creates a temporary list object on
the inside, in case "iter" isn't already a list or a tuple.
(see the implementation of PySequence_Fast() for details).
--
http://
Robert Latest <[EMAIL PROTECTED]> wrote:
> Hrvoje Niksic wrote:
>
> > keywords[:] = (s for s in keywords if s)
>
> Looks good but is so far beyond my own comprehension that I don't dare
> include it in my code ;-)
:-) Worth understanding thought I think - here are some hints
keywords[:]
Robert Latest:
> Fredrik Lundh wrote:
> > keywords = filter(None, keywords) # get "true" items only
>
> Makes seinse. BTW, where can I find all methods of the built-in types?
> Section 3.6 only talks about strings and mentions the list append() method
> only in an example. Am I too stupid to re
Hrvoje Niksic wrote:
> keywords[:] = (s for s in keywords if s)
Looks good but is so far beyond my own comprehension that I don't dare
include it in my code ;-)
robert
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
> keywords = filter(None, keywords) # get "true" items only
Makes seinse. BTW, where can I find all methods of the built-in types?
Section 3.6 only talks about strings and mentions the list append() method
only in an example. Am I too stupid to read the manual, or is th
Hrvoje Niksic <[EMAIL PROTECTED]> writes:
> If you're looking for a quick (no quadratic behavior) and convenient
> way to do it, you can do it like this:
>
> keywords = [s for s in keywords if s != '']
It now occurred to me that a good compromise between convenience and
efficiency that retains th
Robert Latest <[EMAIL PROTECTED]> writes:
> From a list of strings I want to delete all empty ones. This works:
>
> while '' in keywords: keywords.remove('')
If you're looking for a quick (no quadratic behavior) and convenient
way to do it, you can do it like this:
keywords = [s for s in key
Fredrik Lundh wrote:
> creating a new list is always almost the right way to do things like
message = message.replace("always almost", "almost always")
--
http://mail.python.org/mailman/listinfo/python-list
Robert Latest wrote:
>>From a list of strings I want to delete all empty ones. This works:
>
> while '' in keywords: keywords.remove('')
>
> However, to a long-term C programmer this looks like an awkward way of
> accomplishing a simple goal, because the list will have to be re-evaluated
>
Hello,
>From a list of strings I want to delete all empty ones. This works:
while '' in keywords: keywords.remove('')
However, to a long-term C programmer this looks like an awkward way of
accomplishing a simple goal, because the list will have to be re-evaluated
in each iteration. Is ther
13 matches
Mail list logo