473,909 Members | 5,606 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1739
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
4648
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 cool language. I've done Perl and like it, there are a few features of PHP I like but overall am not too excited about it. I have found PHP's strtotime() function to be quite flexible and handy and we make liberal use of it. I have not yet really...
2
4907
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 a web site, runs a Python CGI script on the web server AND passes a string to the CGI Python script that the Python CGI script can store/manipulate/evalute etc.... I know how to connect to the web site and run the CGI Python script using a client...
52
3796
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
3282
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. Here's the script so far: # custom python script /usr/bin/python /home/username/Dev/Python/packZODB.py \ -s"gsgmc.sigma.zettai.net" -b 7 # next program
17
3894
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 XP if it makes any difference. I put a shortcut to myapp.py on the desktop and it shows up as a little green snake icon, which is really cool and Pythonic. When I double click the icon, the app launches just fine and the tkinter interface does...
9
2093
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 script that allows anyone to download, compile (with flags given by user) and install Python and some external modules (e.g. wxPython, PyGTK, Numeric...). I use Python every day and when new version of Python (or some external module) is released, I...
3
2621
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 2.0.3 to the new one, I get error when I visit PuthonScript in the ZMI. "invalid syntax (Script (Python), line 1)"
6
7506
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 like to display a message when the user doesn't have a python2.4 version. if i put, at the top of the script (which can be done with /usr/bin env too): #/usr/bin/python2.4
37
2520
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 server is through mod_python integration with the apache. These are the steps needed for you to be able to run .py script directly
6
9969
by: tatamata | last post by:
Hello. How can I run some Python script within C# program? Thanks, Zlatko
0
10037
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9879
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
11052
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
8099
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7249
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5938
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6140
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3359
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.