[Tutor] Can't figure out why this is printing twice

Lie Ryan lie.1296 at gmail.com
Tue Jun 9 12:17:59 CEST 2009


The Green Tea Leaf wrote:
> You don't happen to have a file called gzip.py in that catalog?
> 
> On Tue, Jun 9, 2009 at 10:03, Mike Hoy<hoym74 at gmail.com> wrote:
>>
>> On Tue, Jun 9, 2009 at 3:00 AM, Mike Hoy <hoym74 at gmail.com> wrote:
>>> Here's the screenshot:
>>>
>>> http://img40.imageshack.us/img40/7124/printtwice.png
>>>
>>> In case the image goes down here's the code:
>>> import gzip
>>> import datetime
>>> date = datetime.date.today()
>>> name = date.strftime('%m-%d-%Y')+'.gz'
>>> print "The name of the file will be", name
>>>
>>> Here's the output:
>>> -----------------------------
>>> mhoy06 at Blackbox:~/code/python$ python gzip2.py
>>> The name of the file will be
>>> The name of the file will be 06-09-2009.gz
>>> -----------------------------
>>> It's Python 2.6.2 on Ubuntu 9.04
>>>
>>> -Mike Hoy
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>

try running this:

print "START"
print "import gzip"
import gzip
print "import datetime"
import datetime
print "date = datetime.date.today()"
date = datetime.date.today()
print "name = date.strftime('%m-%d-%Y')+'.gz'"
name = date.strftime('%m-%d-%Y')+'.gz'
print "print "The name of the file will be", name"
print "The name of the file will be", name
print "END"


and on the shell, what's the output of `ls`?



More information about the Tutor mailing list