Michele Simionato [EMAIL PROTECTED] wrote:
...
I have noticed a while ago that inside generators StopIteration is
automatically trapped, i.e.
def g():
yield 1
raise StopIteration
yield Never reached
only yields 1. Not sure if this is documented behavior, however, of if
David Murmann [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
def join(sep, seq):
return reduce(lambda x, y: x + sep + y, seq, type(sep)())
damn, i wanted too much. Proper implementation:
def join(sep, seq):
if len(seq):
return reduce(lambda x, y: x + sep + y,
On Fri, 30 Sep 2005 09:38:25 -0700, Michael Spencer [EMAIL PROTECTED] wrote:
Terry Reedy wrote:
David Murmann [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
def join(sep, seq):
return reduce(lambda x, y: x + sep + y, seq, type(sep)())
damn, i wanted too much. Proper
Hi again,
i wrote a small patch that changes itertools.chain to take a link
keyword argument. If given, it is iterated between the normal arguments,
otherwise the behavior is unchanged.
I'd like to hear your opinion on both, the functionality and the actual
implementation (as this is one of the
Hi all!
I could not find out whether this has been proposed before (there are
too many discussion on join as a sequence method with different
semantics). So, i propose a generalized .join method on all sequences
with these semantics:
def join(self, seq):
T = type(self)
result = T()
David Murmann wrote:
replace the line
result = result + self + T(item)
with
result = result + self + item
and of course the line
result = T(seq[0])
with
result = seq[0]
--
http://mail.python.org/mailman/listinfo/python-list
David Murmann wrote:
Hi all!
I could not find out whether this has been proposed before (there are
too many discussion on join as a sequence method with different
semantics). So, i propose a generalized .join method on all sequences
with these semantics:
def join(self, seq):
T =
Steven Bethard wrote:
David Murmann wrote:
Hi all!
I could not find out whether this has been proposed before (there are
too many discussion on join as a sequence method with different
semantics). So, i propose a generalized .join method on all sequences
with these semantics:
def
def join(sep, seq):
return reduce(lambda x, y: x + sep + y, seq, type(sep)())
damn, i wanted too much. Proper implementation:
def join(sep, seq):
if len(seq):
return reduce(lambda x, y: x + sep + y, seq)
return type(sep)()
but still short enough
see you,
David.
--
David Murmann wrote:
I could not find out whether this has been proposed before (there are
too many discussion on join as a sequence method with different
semantics). So, i propose a generalized .join method on all sequences
so all you have to do now is to find the sequence base class, and
On Thu, 29 Sep 2005 20:37:31 -0600
Steven Bethard wrote:
I don't like the idea of having to put this on all sequences. If you
want this, I'd instead propose it as a function (perhaps builtin,
perhaps in some other module).
itertools module seems the right place for it.
itertools.chain(*a)
11 matches
Mail list logo