0

Possible Duplicate:
Syntax error on print with Python 3

I want to view the contents of a .tgz file and I found python's tarfile module. I found the following tutorial which looked promising. http://www.doughellmann.com/PyMOTW/tarfile/

Here is my python file below:

import tarfile

tar = tarfile.open("exampleTar.tgz","r")

print tar.getnames()

When I actually execute my python file, I get a carrot sign pointing at the 'r' in the last line and the error message: SyntaxError: invalid syntax.

Community
  • 1
  • 1
SpartaSixZero
  • 2,183
  • 5
  • 27
  • 46

1 Answers1

1

Print is function in python 3.x.

import tarfile

tar = tarfile.open("exampleTar.tgz","r")

print(tar.getnames())
Florin Stingaciu
  • 8,085
  • 2
  • 24
  • 45