<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Brian McCann wrote:
<blockquote cite="mid:93066C069973ED448DC2BCEA9C44A7383BE2EB@efmailx"
 type="cite">
  <meta http-equiv="Content-Type" content="text/html; ">
  <div id="idOWAReplyText9174" dir="ltr">
  <div dir="ltr"><font color="#000000" face="Arial" size="2">Hi,</font></div>
  <div dir="ltr"> </div>
  <div dir="ltr"><font face="Arial" size="2">I'm trying to create a tar
file of the contents of the current directory</font></div>
  <div dir="ltr"> </div>
  <div dir="ltr"><font face="Arial" size="2">right now there is only
one file "text.xml" in the current dir,  I'm using"." current dir as
source<br>
but that gives syntax error<br>
  <br>
any help would be greatly appreciated</font></div>
  <div dir="ltr"><font face="Arial" size="2">--Brian</font></div>
  <div dir="ltr"> </div>
  <div dir="ltr"> </div>
  <div dir="ltr"><font color="#000000" face="Arial" size="2">#!/usr/bin/python</font></div>
  <div dir="ltr"><font color="#000000" face="Arial" size="2">import
string<br>
import os<br>
import sys<br>
import time<br>
import errno<br>
import shutil<br>
import tarfile</font></div>
  <div dir="ltr"> </div>
  <div dir="ltr"><font color="#000000" face="Arial" size="2"><br>
tar = tarfile.open(.,"test.tar.gz", "w:gz)<br>
  </font></div>
  </div>
  <div id="idSignature15335" dir="ltr">
  <div><font color="#000000" face="Arial" size="2">
  <div class="MsoNormal" style="margin: 0in 0in 0pt;">
  <div class="MsoNormal" style="margin: 0in 0in 0pt;"><span
 style="font-size: 10pt; font-family: Arial;"></span></div>
  <span style="font-size: 10pt; font-family: Arial;"></span></div>
  <div class="MsoNormal" style="margin: 0in 0in 0pt;"><font size="3"><font
 face="Times New Roman"> <o:p></o:p></font></font></div>
  </font></div>
  </div>
</blockquote>
Over the course of this thread, I found the following variations on one
line of code.<br>
<br>
Original problem code:   <font color="#000000" face="Arial" size="2">tar
= tarfile.open(.,"test.tar.gz", "w:gz)<br>
(missing quotes around arg[0], and at the end of arg[2])<br>
<br>
SH's First solution:    </font>tar = tarfile(".", "test.tar.gz",
"w:gz")<font color="#000000" face="Arial" size="2"><br>
(quotes around everything, and tarfile.open() becomes tarfile())<br>
<br>
OP's attempt at implementing 1st solution:    </font><font
 color="#000000" face="Arial" size="2">tar =
tarfile.open(".","test.tar.gz",w:gz)<br>
(now the quotes are entirely missing around arg[2])<br>
<br>
SH's concatenation into file what\ I\ wrote:  </font>tar =
tarfile(".", "test.tar.gz", w:gz")<br>
(suddenly the quotes are missing from the beginning of arg[2])<br>
<br>
Result from SH's diff: > tar = tarfile(".", "test.tar.gz", "w:gz")<br>
(the quotes have magically returned).<br>
<br>
Then the conversation devolves into grouchiness on both sides, until JM
steps in with an entirely new solution.  <br>
<br>
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.<br>
<br>
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.<br>
<br>
Cheers,<br>
Cliff<br>
<br>
<br>
</body>
</html>