[issue16150] Implement generator interface in itertools.chain.

2012-10-06 Thread pyos

New submission from pyos:

Since "yield from" made it into Python 3.3, I think it would be useful to chain 
multiple generators and still get a generator, not an iterator. That is, the 
following code:

def f():
yield from itertools.chain(A, B, C)

should be (at least roughly) equivalent to

def f():
yield from A
yield from B
yield from C

while still allowing to send() values to whichever subgenerator is currently 
running or throw() exceptions inside them.

The attached patch adds this functionality to itertools.chain objects.

--
components: Extension Modules
files: itertools-chain-send-throw-and-close.diff
keywords: patch
messages: 172204
nosy: pyos, rhettinger
priority: normal
severity: normal
status: open
title: Implement generator interface in itertools.chain.
versions: Python 3.3, Python 3.4, Python 3.5
Added file: 
http://bugs.python.org/file27455/itertools-chain-send-throw-and-close.diff

___
Python tracker 
<http://bugs.python.org/issue16150>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16150] Implement generator interface in itertools.chain.

2012-10-06 Thread pyos

Changes by pyos :


--
versions: +Python 3.3, Python 3.5

___
Python tracker 
<http://bugs.python.org/issue16150>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16150] Implement generator interface in itertools.chain.

2012-10-06 Thread pyos

Changes by pyos :


--
versions:  -Python 3.3, Python 3.5

___
Python tracker 
<http://bugs.python.org/issue16150>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16150] Implement generator interface in itertools.chain.

2012-10-06 Thread pyos

Changes by pyos :


Added file: http://bugs.python.org/file27456/itertools-chain-doc.diff

___
Python tracker 
<http://bugs.python.org/issue16150>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16150] Implement generator interface in itertools.chain.

2012-10-07 Thread pyos

pyos added the comment:

Updated the patch. Thanks Serhiy Storchaka for comments on the previous one.

--
Added file: 
http://bugs.python.org/file27468/itertools-chain-send-throw-and-close-2.diff

___
Python tracker 
<http://bugs.python.org/issue16150>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16150] Implement generator interface in itertools.chain.

2012-10-07 Thread pyos

Changes by pyos :


Removed file: 
http://bugs.python.org/file27455/itertools-chain-send-throw-and-close.diff

___
Python tracker 
<http://bugs.python.org/issue16150>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16688] Backreferences make case-insensitive regex fail on non-ASCII strings.

2012-12-14 Thread pyos

New submission from pyos:

The title says it all: if a regular expression that makes use of backreferences 
is compiled with `re.I` flag, it will always fail when matched against a string 
that contains characters outside of U+-U+00FF range. I've been unable to 
further narrow the bug down.

A simple example:

>>> import re
>>> r = re.compile(r'(a)\1', re.I)  # should match "aa", "aA", "Aa", or "AA"
>>> r.findall('aa')  # works as expected
['a']
>>> r.findall('aa bcd')  # still works
['a']
>>> r.findall('aa Ā')  # ord('Ā') == 0x0100
[]

The same code works as expected in Python 3.2:

>>> r.findall('aa Ā')
['a']

--
components: Regular Expressions
messages: 177518
nosy: ezio.melotti, mrabarnett, pitrou, pyos
priority: normal
severity: normal
status: open
title: Backreferences make case-insensitive regex fail on non-ASCII strings.
type: behavior
versions: Python 3.3

___
Python tracker 
<http://bugs.python.org/issue16688>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16791] itertools.chain.from_iterable doesn't stop

2012-12-27 Thread pyos

pyos added the comment:

I don't think this is a bug. `b += iter(b)` and `for c in b: b.append(c)` work 
the same way. Also, the tutorial makes it clear that you should duplicate the 
list if you modify it inside a loop; in this case, this can be done either by 
iterating over `b[:]` instead of just `b` or using a list comprehension instead 
of a generator.

--
nosy: +pyos

___
Python tracker 
<http://bugs.python.org/issue16791>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com