On Mon, Jun 8, 2009 at 11:57 AM, Mike Hoy<[email protected]> wrote:
> I have the following code:
>
> import gzip
> import datetime
> date = datetime.date.today()
> name = date.strftime('%m-%d-%Y')+'.gz'
> date.strftime('%m-%d-%Y')+'.gz'
> print "The name of the file will be", name
>
> the output is:
> The name of the file will be
> The name of the file will be 06-08-2009.gz
>
>
> I can't figure out why 'The name of the file will be' is printing twice. Any
> help appreciated.
How exactly are you running this? It seems to work correctly for me.
Looking at your code, the following couple of lines look strange:
> name = date.strftime('%m-%d-%Y')+'.gz'
> date.strftime('%m-%d-%Y')+'.gz'
The first calculates a name based on the current date, and puts the
result in the variable 'name'. The second calculates the name again,
then throws the result away. Why not remove the second line?
--
André Engels, [email protected]
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor