Vishu Viswanathan added the comment:
Thanks for the fast response and clarification. Now I can run my code made
for py2.7 also run in py3.6
I should search and read documentation before reporting.
Thanks
On Thu, Dec 7, 2017 at 8:03 PM, Steven D'Aprano
wrote:
>
> Steven D'Aprano added the
Steven D'Aprano added the comment:
I decided to run the code in 3.5 and 2.7, and now that I know what I'm looking
for, I can see the results buried in the Anaconda notebook.
This is not a bug, zip has been changed in Python 3 to return an iterator
instead of a list. To get the same results as
Serhiy Storchaka added the comment:
In Python 2 zip() returns a list. In Python 3 it returns an iterator (like
itertools.izip() in Python 2). This is an intentional change. For restoring the
Python 2 behavior you should wrap the result of zip() into list(): z =
list(zip(j, k)). The 2to3 comma
Ronald Oussoren added the comment:
If the nested loop is the issue the Python 3 version behaves as expected.
A difference between python2 and python3 is that the zip() builtin returns a
list on python2 and an iterator on python3. This explains the difference in
results in running the code on
Steven D'Aprano added the comment:
I'm sorry, I have no idea how to read an Anaconda notebook file. In the browser
it looks like some sort of nested dictionary. I can find the code:
j = [1, 2, 3, 4]
k = [5, 6, 7, 8]
z = zip(j, k)
for x, y in z:
for m, n in z:
print (x, y, m, n)
b
New submission from Vishu Viswanathan :
The file shows the results by running in Py3.6 and 2.7
In my opinion Py2.7 results matches what I expected.
In this bug or the zip function behaviour is changed with some purpose
--
files: py3.6_vs_py2.7.ipynb
messages: 307803
nosy: Vishu Viswanat