Brian McCann wrote:
Hi,
I'm trying to create a tar file of the contents of the current directory
right now there is only one file "text.xml" in the current dir, I'm
using"." current dir as source
but that gives syntax error
any help would be greatly appreciated
--Brian
#!/usr/bin/python
import string
import os
import sys
import time
import errno
import shutil
import tarfile
tar = tarfile.open(.,"test.tar.gz", "w:gz)
Over the course of this thread, I found the following variations on one
line of code.
Original problem code: tar = tarfile.open(.,"test.tar.gz", "w:gz)
(missing quotes around arg[0], and at the end of arg[2])
SH's First solution: tar = tarfile(".", "test.tar.gz", "w:gz")
(quotes around everything, and tarfile.open() becomes tarfile())
OP's attempt at implementing 1st solution: tar =
tarfile.open(".","test.tar.gz",w:gz)
(now the quotes are entirely missing around arg[2])
SH's concatenation into file what\ I\ wrote: tar = tarfile(".",
"test.tar.gz", w:gz")
(suddenly the quotes are missing from the beginning of arg[2])
Result from SH's diff: > tar = tarfile(".", "test.tar.gz", "w:gz")
(the quotes have magically returned).
Then the conversation devolves into grouchiness on both sides, until JM
steps in with an entirely new solution.
Sheesh. Both of y'all needed to pay more attention to detail. This is
*one* line of code folks. Better yet, get a decent editor that will do
syntax highlighting, so you don't need to pay attention. If quotes
don't close, you need to know that. Train yourself so that looking for
unclosed quotes, parens, brackets, etc. becomes second nature. And make
sure you quote ALL strings. Some languages are forgiving on this
count. Python is not.
Blessings to all, and may all find their good cheer restored by some
rest. I offer you both a virtual pint. You seem like you could use it.
Cheers,
Cliff
--
http://mail.python.org/mailman/listinfo/python-list