473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Python Script Bug

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
Oct 23 '08 #1
2 1719
On Thu, Oct 23, 2008 at 11:54 AM, ma******@gmail.com <ma******@gmail.comwrote:
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)
input() does not do what you think it does. You want raw_input().
raw_input() takes a string to prompt the user with and returns the
string the user enters.
You'll then pass the string to time.strptime() (along with a format
string) to parse it into a time tuple. You'll then pass part of the
time tuple to the datetime.date() constructor to get a date object.
global t
'global' declarations are only allowed (and only make sense) inside a
function. Remove the above line.

Based on some of the errors you've made, I'd recommend reading through
Python's fine tutorial before going any further:
http://docs.python.org/tutorial/index.html

Cheers,
Chris
--
Follow the path of the Iguana...
http://rebertia.com
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
--
http://mail.python.org/mailman/listinfo/python-list
Oct 23 '08 #2
Chris Rebert wrote:
>global t

'global' declarations are only allowed (and only make sense) inside a
function. Remove the above line.
Global statements are *allowed* anywhere (by BDFL decision - does not
hurt and he wants to keep code in and out of functions as identical as
possible), but rest of statement I agree with.

Oct 24 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Erik Johnson | last post by:
This is somewhat a NEWBIE question... My company maintains a small RDBS driven website. We currently generate HTML using PHP. I've hacked a bit in Python, and generally think it is a rather...
2
by: DeepBleu | last post by:
When one is using an HTML form via a web broswer, the user submits the form contents and these are passed to a CGI Python script on the web server. I need to write a client script that connects to...
52
by: Olivier Scalbert | last post by:
Hello , What is the python way of doing this : perl -pi -e 's/string1/string2/' file ? Thanks Olivier
4
by: Tom Purl | last post by:
I just wrote a Python script that is going to be called from bash script. If the Python script fails, I want the bash script to also stop running. Unfortunately, I can't seem to get that to work. ...
17
by: Paul Rubin | last post by:
Dumb question from a Windows ignoramus: I find myself needing to write a Python app (call it myapp.py) that uses tkinter, which as it happens has to be used under (ugh) Windows. That's Windows...
9
by: TPJ | last post by:
First I have to admit that my English isn't good enough. I'm still studying and sometimes I just can't express what I want to express. A few weeks ago I've written 'Python Builder' - a bash...
3
by: krzychu | last post by:
Hi, I have installed brand new platform - Zope-2-7-6, Python 2.4.1, Plone 2.0.5, OS Debian 1:3.3.6-2. After import a old Plone site from the following platform Zope-2-7-4, Python 2.3.3, Plone...
6
by: manatlan | last post by:
I've got a trouble, and i think that anybody there can help me I've got a python script which i distribute in somes packages for *nix. This script is full of python and need python 2.4 ! And i'd...
37
by: John Salerno | last post by:
I contacted my domain host about how Python is implemented on their server, and got this response: ------------------- Hello John, Please be informed that the implementation of python in our...
6
by: tatamata | last post by:
Hello. How can I run some Python script within C# program? Thanks, Zlatko
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.