Python Forum
AttributeError when - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: AttributeError when (/thread-2061.html)



AttributeError when - sunilka - Feb-15-2017

using python3.6 and i'm trying to use pycharm as my IDE. below code works well on the interpreter from command list but not from pycharm.
any help appreciated ?

import tarfile

with tarfile.open("sample.tar","w") as tar:
    for name in [ "foo", "bar", "quux"]:
        tar.add(name)
.
.
Error:
with tarfile.open("sample.tar","w") as tar: AttributeError: module 'tarfile' has no attribute 'open'



RE: AttributeError when - Larz60+ - Feb-15-2017

I tried it and it works fine with python3.4
I did use real file names in place of 'foo', 'bar' and 'quix'
(which you would need for it to work.

Try changing those to real files and see if it works.


RE: AttributeError when - Ofnuts - Feb-15-2017

Have you written your own tarfile.py, by any chance?