Python Script Bug

Benjamin Kaplan benjamin.kaplan at case.edu
Thu Oct 23 21:45:55 CEST 2008


On Thu, Oct 23, 2008 at 2:54 PM, max.caly at gmail.com <max.caly at gmail.com>wrote:

> Hello everyone,
> I would like to know what isn't good in my script.
> #!/usr/bin/python
> # -*- coding: iso-8859-15 -*-
> from time import strftime
> import datetime
> t = input(datetime.date)
> global t
> print t.strftime("Day %w of the week a %A . Day %d of the month (%B).
> ")
> print t.strftime("Day %j of the year (%Y), in week %W of the year.")
> raw_input()
> i get error :
>    print t.strftime("Day %w of the week a %A . Day %d of the month
> (%B). ")
> AttributeError: 'tuple' object has no attribute 'strftime'
> Thanks for your Help
> --


1) why are you using input and raw_input? Are you trying to use them as
breakpoints?

2) Do you understand what t.strftime is doing? It is trying to access an
attribute of t (a tuple) called 'strftime'. A tuple does not have an
attribute by that name, so it throws an AttributeError. You probably want

print strftime("Day %w of the week a %A . Day %d of the month (%B).", t)
#this checks globals() for an attribute called strftime



> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081023/8f9d203d/attachment.html>


More information about the Python-list mailing list