[issue21964] inconsistency in list-generator comprehension with yield(-from)

2014-07-14 Thread hakril

hakril added the comment:

I found something else, I think it worth mentioning it.

This side-effect allows to create generators that return other values that 
None. And the CPython's behavior is not the same for all versions:

 {(yield i) : i for i in range(2)}
generator object dictcomp at 0x7f0b98f41410
 list(_)
# python3.(3,4,5)
[0, 1]
# python3.2
[0, 1, {None: 1}] #  python3.2 appends the generator's return value.

--
versions: +Python 3.2, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21964
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21964] inconsistency in list-generator comprehension with yield(-from)

2014-07-11 Thread hakril

New submission from hakril:

Will playing with generators and `yield from` I found some inconsistency.

list comprehension with yield(-from) would return a generator.
generator comprehension would yield some None in the middle of the expected 
values.

Examples:
l = [abc, range(3)]
g1 = [(yield from i) for i in l]
print(g)
generator object listcomp at 0x7f5ebd58b690
print(list(g))
['a', 'b', 'c', 0, 1, 2]  # this result is super cool !

g2 = ((yield from i) for i in l)
print(g2)
generator object genexpr at 0x7f5ebd58b6e0
print(list(g2))
['a', 'b', 'c', None, 0, 1, 2, None]


For `g1`: it returns a generator because the listcomp contains a `yield from`.

For `g2` it append None because it yield the return value of `yield from i`.
It could be rewritten as:
def comp(x):
for i in x:
yield (yield from i)

--
components: Interpreter Core
messages: 222811
nosy: hakril
priority: normal
severity: normal
status: open
title: inconsistency in list-generator comprehension with yield(-from)
type: behavior
versions: Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21964
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21947] `Dis` module doesn't know how to disassemble generators

2014-07-09 Thread hakril

New submission from hakril:

The `dis` module doesn't know how to disassemble generator object because it 
has no idea about the `gi_code` attribute.
I made a (very) little patch to change this behavior.

If there is a valid reason to not let the `dis` module disassemble generator, I 
would be glad to know it.

--
components: Extension Modules
files: dis_generator.patch
keywords: patch
messages: 222619
nosy: hakril
priority: normal
severity: normal
status: open
title: `Dis` module doesn't know how to disassemble generators
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file35914/dis_generator.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21947
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21947] `Dis` module doesn't know how to disassemble generators

2014-07-09 Thread hakril

hakril added the comment:

Here is a try for a better patch.
Added a unit test and updated the doc.

--
Added file: http://bugs.python.org/file35918/dis_generator2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21947
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com