This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: zip() python 3 documentation not working at all !
Type: compile error Stage: resolved
Components: Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Muhammad Salem, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-02-27 10:38 by Muhammad Salem, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg288631 - (view) Author: Muhammad Salem (Muhammad Salem) Date: 2017-02-27 10:38
this code from the python documentation itself not working!

>>> x = [1, 2, 3]
>>> y = [4, 5, 6]
>>> zipped = zip(x, y)

this code is copied from the python 3 official documentation itself even though it is working for me I am using python 3.5.2 on ubuntu 16.04 LTS
msg288633 - (view) Author: Muhammad Salem (Muhammad Salem) Date: 2017-02-27 10:47
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-63-0f18e3fc2836> in <module>()
      6 x = [1, 2, 3]
      7 y = [4, 5, 6]
----> 8 zip(x, y)

TypeError: 'tuple' object is not callable
msg288636 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-02-27 11:14
Your example works for me.

>>> x = [1, 2, 3]
>>> y = [4, 5, 6]
>>> zipped = zip(x, y)
>>> print(zipped)
<zip object at 0xb6ff706c>
>>> print(list(zipped))
[(1, 4), (2, 5), (3, 6)]

I guess you have overridden the builtin function "zip" by setting the global variable "zip".

>>> zip = (7, 8)
>>> zipped = zip(x, y)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object is not callable
History
Date User Action Args
2022-04-11 14:58:43adminsetgithub: 73850
2017-02-27 11:14:19serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg288636

resolution: not a bug
stage: resolved
2017-02-27 10:47:29Muhammad Salemsetmessages: + msg288633
components: - Interpreter Core
2017-02-27 10:38:18Muhammad Salemcreate