Re: [Tutor] Microsoft Access

2007-12-27 Thread Darren Williams
Typing 'Using MS Access from Python' into Google returned a few results, one in 
particular - http://www.markcarter.me.uk/computing/python/ado.html

Hope that helps.
  - Original Message - 
  From: Jim Morcombe 
  To: python tutor mailing list 
  Sent: Friday, December 28, 2007 1:38 AM
  Subject: [Tutor] Microsoft Access


  Are there any simple tutorials on using MS Access from Python?

  Jim



--


  ___
  Tutor maillist  -  Tutor@python.org
  http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Take if offline

2007-09-25 Thread Darren Williams
So by your own rules, you should have sent that to the offending user(s).

- Original Message - 
From: Hansen, Mike [EMAIL PROTECTED]
To: python tutor tutor@python.org
Sent: Tuesday, September 25, 2007 2:27 PM
Subject: [Tutor] Take if offline


 Anytime someone posts in HTML, or posts without a subject, or
 accidentally
 hijacks a thread, or top-posts, or writes in caps, a couple of posters
 pop up
 and complain. Rather than posting to the entire list, I think it'd be
 best if
 you send your complaint directly to the offending user. I'd prefer to
 read
 about Python not read lessons in net/mail-list etiquette. 
 
 Thanks,
 
 Mike
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Take if offline

2007-09-25 Thread Darren Williams
All jokes aside now (glad you took it that way Mike).  Maybe I havn't gave 
the tutor enough attention, but I have never witnessed someone jump down 
anothers throat because they posted in all caps, didn't enter a subject 
etc... etc...  The one time I have seen an argument (well heated debate) was 
about a subject entitled 'Losing the expressiveness of C' (or something 
similar), which I found pretty interesting.

- Original Message - 
From: Shawn Milochik [EMAIL PROTECTED]
To: Darren Williams [EMAIL PROTECTED]
Sent: Tuesday, September 25, 2007 3:06 PM
Subject: Re: [Tutor] Take if offline


 No, not really. He had to give everyone the rule once. Otherwise, he'd
 have to do it a hundred times a day, and monitor every single post to
 find out who he had to inform. He'd end up doing not much else with
 his life, and would flee to a monastery and give up coding forever.
 You wouldn't want that to happen, would you?



 On 9/25/07, Darren Williams [EMAIL PROTECTED] wrote:
 So by your own rules, you should have sent that to the offending user(s).

 - Original Message -
 From: Hansen, Mike [EMAIL PROTECTED]
 To: python tutor tutor@python.org
 Sent: Tuesday, September 25, 2007 2:27 PM
 Subject: [Tutor] Take if offline


  Anytime someone posts in HTML, or posts without a subject, or
  accidentally
  hijacks a thread, or top-posts, or writes in caps, a couple of posters
  pop up
  and complain. Rather than posting to the entire list, I think it'd be
  best if
  you send your complaint directly to the offending user. I'd prefer to
  read
  about Python not read lessons in net/mail-list etiquette.
 
  Thanks,
 
  Mike
  ___
  Tutor maillist  -  Tutor@python.org
  http://mail.python.org/mailman/listinfo/tutor
 
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor



 -- 
 Please read:
 http://milocast.com/2007/07/31/this-i-believe/
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Question from a newbie

2007-07-18 Thread Darren Williams
I have exactly the same problem using PythonWin.  I know it's not saving 
because in the location where I am saving my program to, nothing appears, I 
can even search my whole computer for the file but nothing...

I just use Komodo Edit for writing and saving the final versions and 
PythonWin for testing lines of code up until then.

- Original Message - 
From: Luke Paireepinart [EMAIL PROTECTED]
To: Junaid.Khan/Finance/Lahore [EMAIL PROTECTED]
Cc: tutor@python.org
Sent: Wednesday, July 18, 2007 10:40 AM
Subject: Re: [Tutor] Question from a newbie


Junaid.Khan/Finance/Lahore wrote:

 Hi

 I am totally new to Python. I downloaded it and I really like it as
 its very simple but I came across a small problem. My question is:

 How can I save something in Python. I tried to save it but it don’t
 save it. Even I tried to add *.py as extension in the end of file name
 but still it doesn’t works. I coded a simple program but don’t know
 how to save it now in the PythonWin Editor. Let me tell you that I
 have installed the windows xp version of Python.

How do you know it's not saving?
The way you save in PythonWin should be similar to saving in another
program, but I haven't used it in a few years so I may have forgotten
something.
Thanks for giving us your IDE and OS.
-Luke

 **Muhammad Junaid Khan**

 

 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] while Loop

2007-07-18 Thread Darren Williams
Hi all,

I'm writing a calculator for an online game that I used to play but don't seem 
to be able to break out of the while loop, the program will just go over and 
over the loop, crashing the program and I don't know if Python is just really 
slow at this type of thing or i'm doing it completely wrong in Python (the 
equivalent code in JavaScript works fine).

Python code -

def main():
usedPocketsOne = 192000
junkiesOne = 500
labSpaceOne = 0

resultOne = 0
while usedPocketsOne  (junkiesOne - labSpaceOne) * 17:
resultOne = resultOne + 1
usedPocketsOne = (UsedPocketsOne - junkiesOne + labSpaceOne) * 17
junkiesOne = junkiesOne + 1

main()

And the JavaScript equivalent (incase there are any stalwarts beside Alan here) 
-
 
function main() {
var usedPocketsOne = 192000
var junkiesOne = 500
var labSpaceOne = 0

var resultOne = 0
while (usedPocketsOne  junkiesOne - labSpaceOne * 17) {
resultOne = resultOne + 1
usedPocketsOne = usedPocketsOne - junkiesOne + labSpaceOne * 17
junkiesOne = junkiesOne + 1
}
}

Thanks in advance for any help :)___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] while Loop

2007-07-18 Thread Darren Williams
Luke and Kent, you're right, I didn't think JavaScript calculated 
multiplaction and division before addition and subtraction but seems it does 
:)

I dunno what you mean about usedPocketsOne not being defined, didn't I 
define it with usedPocketsOne = 192000?

- Original Message - 
From: Luke Paireepinart [EMAIL PROTECTED]
To: Darren Williams [EMAIL PROTECTED]
Cc: tutor@python.org
Sent: Wednesday, July 18, 2007 11:57 AM
Subject: Re: [Tutor] while Loop


 Darren Williams wrote:
 Hi all,
  I'm writing a calculator for an online game that I used to play but 
 don't seem to be able to break out of the while loop, the program will 
 just go over and over the loop, crashing the program and I don't know if 
 Python is just really slow at this type of thing or i'm doing it 
 completely wrong in Python (the equivalent code in JavaScript works 
 fine).
 I don't think you're doing it completely wrong, just partially :)
 And I doubt that, if it's quick in Javascript, it will be any slower in 
 Python, since Javascript is interpreted as well, but by the browser while 
 it's simultaneously downloading the content of the webpage and rendering 
 it to the screen.
 Also, I'm pretty sure the code here is not equivalent to the Javascript 
 code you included (specific remarks below.)
  Python code -
  def main():
 usedPocketsOne = 192000
 junkiesOne = 500
 labSpaceOne = 0
  resultOne = 0
 while usedPocketsOne  (junkiesOne - labSpaceOne) * 17:
 I don't know much about Javascript, but doesn't it have order of 
 operations?
 For example,
 usedPocketsOne  junkiesOne - labSpaceOne * 17
 is generally assumed to be
 x = labSpaceOne * 17
 y = junkiesOne - x
 usedPocketsOne  y


 Whereas your Python equivalent, with the parenthesis,
 usedPocketsOne  (junkiesOne - labSpaceOne) * 17

 changes the order of operations (forces the subtraction before the 
 multiplication)
 and hence changes the resulting value.  That is, unless Javascript 
 evaluates left-to-right with no operator heirarchy (which I would be 
 saddened to learn, if it's true.)
 resultOne = resultOne + 1
 usedPocketsOne = (UsedPocketsOne - junkiesOne + labSpaceOne) * 17
 This shouldn't even run - you should get a syntax error because 
 UsedPocketsOne is not defined anywhere else in the program (that you've 
 shown us.)
 Perhaps you're running it in IDLE with no subprocess and some value for 
 UsedPocketsOne is hanging around (from previous edits of the program, or 
 interpreter session, or something else) and mucking up the works?
 -Luke


 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] while Loop

2007-07-18 Thread Darren Williams
Oops, didn't notice the uppercase U, thanks Luke.

- Original Message - 
From: Luke Paireepinart [EMAIL PROTECTED]
To: Darren Williams [EMAIL PROTECTED]
Cc: tutor@python.org
Sent: Wednesday, July 18, 2007 3:08 PM
Subject: Re: [Tutor] while Loop


 Darren Williams wrote:
 Luke and Kent, you're right, I didn't think JavaScript calculated 
 multiplaction and division before addition and subtraction but seems 
 it does :)

 I dunno what you mean about usedPocketsOne not being defined, didn't I 
 define it with usedPocketsOne = 192000?
 no, I said UsedPocketsOne was not defined.  Note the different starting 
 letter.
 Python is case senstitive, meaning usedPocketsOne is not the same as 
 UsedPocketsOne.
 So yes, you defined usedPocketsOne with the assignment to 192000, but 
 you did not define UsedPocketsOne.
 
 Note what happens when I test your code:
  def main():
 
 usedPocketsOne = 192000
 junkiesOne = 500
 labSpaceOne = 0
 
 resultOne = 0
 while usedPocketsOne  (junkiesOne - labSpaceOne) * 17:
 resultOne = resultOne + 1
 usedPocketsOne = (UsedPocketsOne - junkiesOne + labSpaceOne) * 17
 

  main()
 
 Traceback (most recent call last):
  File pyshell#6, line 1, in -toplevel-
main()
  File pyshell#5, line 10, in main
usedPocketsOne = (UsedPocketsOne - junkiesOne + labSpaceOne) * 17
 NameError: global name 'UsedPocketsOne' is not defined
 
 You should get a similar error, unless you've somehow defined 
 UsedPocketsOne somewhere else.
 HTH,
 -Luke
 
 Correction of previous e-mail: This raises a NameError, not a 
 SyntaxError, as I said before.  sorry about that.
 
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] CGI Calculator

2007-07-16 Thread Darren Williams
Hi all,

I am a Python convert coming from a JavaScript background (as you can probably 
tell) and am currently writing my first application using Python which will be 
a calculator for an online game I used to play (thought it would be a decent 
first project) but am not sure on the syntax for referencing an HTML form input 
field, I tried this (which returns an error) - 

XHTML form - 

?xml version=1.0 encoding=UTF-8?
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
titleDopeWars Junkie Calculator/title
/head
body
center
form method=post action=http://newspyn.com/cgi-bin/JunkieCalc.py;
pbCoat Size:/b#32;input type=text name=coatSize
pbUsed Pockets:/b#32;input type=text name=usedPockets
pbLab Space:/b#32;input type=text name=labSpace
pbTotal Junkies:/b#32;input type=text name=totalJunkies
pbDealer Visits Remaining:/b#32;input type=text name=DVR
pinput type=submit value=Submit
/form
/body
/html

junkieCalc.py - 

#!/usr/bin/env python

import cgi

def main():
print Content-type: text/html\n
form = cgi.FieldStorage()
if form.has_key(coatSize) and form.has_key(usedPockets) and 
form.has_key(labSpace) and form.has_key(totalJunkies) and 
form.has_key(DVR) and form[coatSize].value !=  and 
form[usedPockets].value !=  and form[labSpace].value !=  and 
form[totalJunkies].value !=  and form[DVR].value != :
Tokens = 0
while usedPockets  (totalJunkies - labSpace) * 17:
Tokens = Tokens + 1
usedPockets = (usedPockets - totalJunkies + labSpace) * 17
totalJunkies = totalJunkies + 1
print Tokens
else:
print Try again

main()

This is the error i'm getting - 

Traceback (most recent call last): File 
D:\inetpub\vhosts\newspyn.com\cgi-bin\JunkieCalc.py, line 23, in ? main() 
File D:\inetpub\vhosts\newspyn.com\cgi-bin\JunkieCalc.py, line 10, in main 
while usedPockets  (totalJunkies - labSpace) * 17: UnboundLocalError: local 
variable 'usedPockets' referenced before assignment

Thanks in advance for any help :)___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] CGI Calculator

2007-07-16 Thread Darren Williams
Ok, now i've modified my script but am getting another error, i've commented 
a few useless (hopefully) lines out -

#!/usr/bin/env python

import cgitb; cgitb.enable()
import cgi

def main():
print Content-type: text/html\n
form = cgi.FieldStorage()
#if form.has_key(coatSize) and form.has_key(usedPockets) and 
form.has_key(labSpace) and form.has_key(totalJunkies) and 
form.has_key(DVR) and form[coatSize].value !=  and 
form[usedPockets].value !=  and form[labSpace].value !=  and 
form[totalJunkies].value !=  and form[DVR].value != :
Tokens = 0
coatSize = form[coatSize].value
usedPockets = form[usedPockets].value
labSpace = form[labSpace].value
totalJunkies = form[totalJunkies].value
DVR = form[DVR].value

while usedPockets  totalJunkies - labSpace * 17:
Tokens = Tokens + 1
usedPockets = (usedPockets - totalJunkies + labSpace) * 17
totalJunkies = totalJunkies + 1
print Tokens
#else:
#print Try again

main()

Here's the error using the CGI Traceback Module -

  D:\inetpub\vhosts\newspyn.com\cgi-bin\JunkieCalc.py
 21 print Tokens

 22 #else:

 23 #print Try again... beeyatch

 24

 25 main()

  main = function main
   D:\inetpub\vhosts\newspyn.com\cgi-bin\JunkieCalc.py in main()
 15 DVR = form[DVR].value

 16

 17 while usedPockets  totalJunkies - labSpace * 17:

 18 Tokens = Tokens + 1

 19 usedPockets = (usedPockets - totalJunkies + labSpace) * 
17

  usedPockets = '192000', totalJunkies = '200', labSpace = '0'

TypeError: unsupported operand type(s) for -: 'str' and 'str'
  args = (unsupported operand type(s) for -: 'str' and 'str',)



It's confused me - it says I can't subtract a string from a string but then 
gives the value's of the variables (that I randomly entered into the form) 
at the bottom - usedPockets = '192000', totalJunkies = '200', labSpace = '0'

Thanks in advance for any help :)

- Original Message - 
From: Eric Brunson [EMAIL PROTECTED]
To: Darren Williams [EMAIL PROTECTED]
Cc: tutor@python.org
Sent: Monday, July 16, 2007 12:50 PM
Subject: Re: [Tutor] CGI Calculator


 Darren Williams wrote:
 Hi all,
  I am a Python convert coming from a JavaScript background

 Welcome to Python, Darren.

 (as you can probably tell) and am currently writing my first application 
 using Python which will be a calculator for an online game I used to play 
 (thought it would be a decent first project) but am not sure on the 
 syntax for referencing an HTML form input field, I tried this (which 
 returns an error) -
  XHTML form -
  ?xml version=1.0 encoding=UTF-8?
 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN 
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
 html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
 head
 titleDopeWars Junkie Calculator/title
 /head
 body
 center
 form method=post 
 action=http://newspyn.com/cgi-bin/JunkieCalc.py;
 pbCoat Size:/b#32;input type=text name=coatSize
 pbUsed Pockets:/b#32;input type=text 
 name=usedPockets
 pbLab Space:/b#32;input type=text name=labSpace
 pbTotal Junkies:/b#32;input type=text 
 name=totalJunkies
 pbDealer Visits Remaining:/b#32;input type=text 
 name=DVR
 pinput type=submit value=Submit
 /form
 /body
 /html
  junkieCalc.py -
  #!/usr/bin/env python
  import cgi
  def main():
 print Content-type: text/html\n
 form = cgi.FieldStorage()
 if form.has_key(coatSize) and form.has_key(usedPockets) and 
 form.has_key(labSpace) and form.has_key(totalJunkies) and 
 form.has_key(DVR) and form[coatSize].value !=  and 
 form[usedPockets].value !=  and form[labSpace].value !=  and 
 form[totalJunkies].value !=  and form[DVR].value != :
 Tokens = 0
 while usedPockets  (totalJunkies - labSpace) * 17:
 Tokens = Tokens + 1
 usedPockets = (usedPockets - totalJunkies + labSpace) * 17
 totalJunkies = totalJunkies + 1
 print Tokens
 else:
 print Try again
  main()
  This is the error i'm getting -
  Traceback (most recent call last): File 
 D:\inetpub\vhosts\newspyn.com\cgi-bin\JunkieCalc.py, line 23, in ? 
 main() File D:\inetpub\vhosts\newspyn.com\cgi-bin\JunkieCalc.py, line 
 10, in main while usedPockets  (totalJunkies - labSpace) * 17: 
 UnboundLocalError: local variable 'usedPockets' referenced before 
 assignment

 So, you get an error on line 10, which is:

 while usedPockets  (totalJunkies - labSpace) * 17:

 and it says that your variable is referenced before assignment.  Have you 
 assigned a value to it?  In your intro you ask how to reference an HTML 
 form field, well you're already doing it in your if statement: 
 form[labSpace].value, so if you want a local variable named usedPockets, 
 you should assign a value to it, like:  usedPockets = 
 form[usedPockets].value

Re: [Tutor] CGI Calculator

2007-07-16 Thread Darren Williams
Now another problem - the script is just printing the word 'Tokens' over and 
over again, it's supposed to work like this (JavaScript version made by 
me) - http://nazkyn.brinkster.net/1.8.html

Thanks in advance for any help :)

- Original Message - 
From: Eric Brunson [EMAIL PROTECTED]
To: Darren Williams [EMAIL PROTECTED]
Cc: tutor@python.org
Sent: Monday, July 16, 2007 2:01 PM
Subject: Re: [Tutor] CGI Calculator


 Darren Williams wrote:
 Ok, now i've modified my script but am getting another error, i've 
 commented a few useless (hopefully) lines out -

 #!/usr/bin/env python

 import cgitb; cgitb.enable()
 import cgi


 [snip]
 17 while usedPockets  totalJunkies - labSpace * 17:

 18 Tokens = Tokens + 1

 19 usedPockets = (usedPockets - totalJunkies + labSpace) 
 * 17

  usedPockets = '192000', totalJunkies = '200', labSpace = '0'

 TypeError: unsupported operand type(s) for -: 'str' and 'str'
  args = (unsupported operand type(s) for -: 'str' and 'str',)


 What does dog - cat mean?  Similarly, what does 100 - 12 mean? 
 It's not the same in Python as 100 - 12, because those are numbers, 100 
 and 12 are strings which happen to represent numbers.

 You need to coerce those strings into integers, maybe like this:

 usedPockets = int(form[usedPockets].value)

 When you do that, you'll probably need to catch any exception that could 
 occur if the string can't be converted.



 It's confused me - it says I can't subtract a string from a string but 
 then gives the value's of the variables (that I randomly entered into the 
 form) at the bottom - usedPockets = '192000', totalJunkies = '200', 
 labSpace = '0'


 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] CGI Calculator

2007-07-16 Thread Darren Williams
That's just printing Tokens: 1 Tokens: 2 ... Tokens: 6000 etc...

Can you recommend any tutorials for me?
 
- Original Message - 
From: Eric Brunson [EMAIL PROTECTED]
To: Darren Williams [EMAIL PROTECTED]
Cc: tutor@python.org
Sent: Monday, July 16, 2007 2:48 PM
Subject: Re: [Tutor] CGI Calculator


 Darren Williams wrote:
 Now another problem - the script is just printing the word 'Tokens' 
 over and over again, it's supposed to work like this (JavaScript 
 version made by me) - http://nazkyn.brinkster.net/1.8.html

 Thanks in advance for any help :)
 
 It's doing exactly what you've told it to do:
 
   while usedPockets  totalJunkies - labSpace * 17:
   Tokens = Tokens + 1
   usedPockets = (usedPockets - totalJunkies + labSpace) * 17
   totalJunkies = totalJunkies + 1
   print Tokens
 
 The print statement is inside the while loop and you've quoted the work 
 Tokens so it's printing the string rather than the variable.
 
 How about grabbing a short tutorial on Python and reading through it to 
 better understand the differences between Python and Javascript.  If 
 you're an experienced JS programmer it shouldn't take very long.
 
 This is probably closer is what I infer you're looking for:
 
   while usedPockets  totalJunkies - labSpace * 17:
   Tokens = Tokens + 1
   usedPockets = (usedPockets - totalJunkies + labSpace) * 17
   totalJunkies = totalJunkies + 1
   print Tokens: %s % Tokens
 
 e.
 

 - Original Message - From: Eric Brunson [EMAIL PROTECTED]
 To: Darren Williams [EMAIL PROTECTED]
 Cc: tutor@python.org
 Sent: Monday, July 16, 2007 2:01 PM
 Subject: Re: [Tutor] CGI Calculator


 Darren Williams wrote:
 Ok, now i've modified my script but am getting another error, i've 
 commented a few useless (hopefully) lines out -

 #!/usr/bin/env python

 import cgitb; cgitb.enable()
 import cgi


 [snip]
 17 while usedPockets  totalJunkies - labSpace * 17:

 18 Tokens = Tokens + 1

 19 usedPockets = (usedPockets - totalJunkies + 
 labSpace) * 17

  usedPockets = '192000', totalJunkies = '200', labSpace = '0'

 TypeError: unsupported operand type(s) for -: 'str' and 'str'
  args = (unsupported operand type(s) for -: 'str' and 'str',)


 What does dog - cat mean?  Similarly, what does 100 - 12 
 mean? It's not the same in Python as 100 - 12, because those are 
 numbers, 100 and 12 are strings which happen to represent numbers.

 You need to coerce those strings into integers, maybe like this:

 usedPockets = int(form[usedPockets].value)

 When you do that, you'll probably need to catch any exception that 
 could occur if the string can't be converted.



 It's confused me - it says I can't subtract a string from a string 
 but then gives the value's of the variables (that I randomly entered 
 into the form) at the bottom - usedPockets = '192000', totalJunkies 
 = '200', labSpace = '0'




 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] CGI error

2007-07-13 Thread Darren Williams
 Hi all  

I have a Windows hosting account with lunarpages.com and am having a bit of 
trouble with CGI. I have enabled both CGI and Python in the control panel and 
made sure the permissions for all my CGI scripts are set to both readable and 
executable for all users but I keep getting the same 'The specified CGI 
application misbehaved by not returning a complete set of HTTP headers' error. 

The script that i'm trying to execute (example_7.1.py) - 


Code: [Download]
  1.. #!/usr/bin/python
  2.. 
  3.. # Import the CGI module
  4.. import cgi
  5.. 
  6.. # Required header that tells the browser how to render the HTML.
  7.. print Content-Type: text/html\n\n
  8.. 
  9.. # Define function to generate HTML form.
  10.. def generate_form():
  11.. print HTML\n
  12.. print HEAD\n
  13.. print \tTITLEInfo Form/TITLE\n
  14.. print /HEAD\n
  15.. print BODY BGCOLOR = white\n
  16.. print \tH3Please, enter your name and age./H3\n
  17.. print \tTABLE BORDER = 0\n
  18.. print \t\tFORM METHOD = post ACTION = \
  19.. \example_7.1.cgi\\n
  20.. print \t\tTRTHName:/THTDINPUT type = text \
  21.. name = \name\/TDTR\n
  22.. print \t\tTRTHAge:/THTDINPUT type = text name = \
  23.. \age\/TD/TR\n
  24.. print \t/TABLE\n
  25.. print \tINPUT TYPE = hidden NAME = \action\ VALUE = \
  26.. \display\\n
  27.. print \tINPUT TYPE = submit VALUE = \Enter\\n
  28.. print \t/FORM\n
  29.. print /BODY\n
  30.. print /HTML\n
  31.. 
  32.. # Define function display data.
  33.. def display_data(name, age):
  34.. print HTML\n
  35.. print HEAD\n
  36.. print \tTITLEInfo Form/TITLE\n
  37.. print /HEAD\n
  38.. print BODY BGCOLOR = white\n
  39.. print name, , you are, age, years old.
  40.. print /BODY\n
  41.. print /HTML\n
  42.. 
  43.. # Define main function.
  44.. def main():
  45.. form = cgi.FieldStorage()
  46.. if (form.has_key(action) and form.has_key(name) \
  47.. and form.has_key(age)):
  48..  if (form[action].value == display):
  49.. display_data(form[name].value, form[age].value)
  50.. else:
  51..  generate_form()
  52.. 
  53.. # Call main function.
  54.. main()
  55.. 


And the server log - 

#Software: Microsoft Internet Information Services 6.0 
#Version: 1.0 
#Date: 2007-07-13 12:11:28 
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem 
cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) 
cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes 
time-taken 
2007-07-13 12:11:27 W3SVC12090 ARCTURUS 209.200.254.99 GET /Index.aspx - 80 - 
74.14.92.189 HTTP/1.1 
Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4
 - - newspyn.com 200 0 0 995 403 593 
2007-07-13 12:11:27 W3SVC12090 ARCTURUS 209.200.254.99 GET 
/Images/ComingSoon.png - 80 - 74.14.92.189 HTTP/1.1 
Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4
 - http://newspyn.com/ newspyn.com 404 0 2 1819 374 93 
2007-07-13 12:11:30 W3SVC12090 ARCTURUS 209.200.254.99 GET 
/Images/development.bmp - 80 - 74.14.92.189 HTTP/1.1 
Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4
 - http://newspyn.com/ newspyn.com 200 0 0 1000335 375 2984 
2007-07-13 12:11:30 W3SVC12090 ARCTURUS 209.200.254.99 GET /favicon.ico - 80 - 
74.14.92.189 HTTP/1.1 
Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4
 - - newspyn.com 404 0 2 1819 334 93 
2007-07-13 12:11:51 W3SVC12090 ARCTURUS 209.200.254.99 GET 
/cgi-bin/example_1.1.cgi - 80 - 74.14.92.189 HTTP/1.1 
Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4
 - - newspyn.com 404 0 3 1819 426 93 
2007-07-13 12:12:05 W3SVC12090 ARCTURUS 209.200.254.99 GET /cgi-bin - 80 - 
74.14.92.189 HTTP/1.1 
Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4
 - - newspyn.com 404 0 2 1819 410 109 
#Software: Microsoft Internet Information Services 6.0 
#Version: 1.0 
#Date: 2007-07-13 13:03:04 
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem 
cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) 
cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes 
time-taken 
2007-07-13 13:03:04 W3SVC12090 ARCTURUS 209.200.254.99 GET 
/cgi-bin/example_1.1.cgi - 80 - 74.14.92.189 HTTP/1.1 
Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.4)+Gecko/20070515+Firefox/2.0.0.4
 - - newspyn.com 404 0 3 1819 426 218 
#Software: Microsoft Internet Information Services 6.0 
#Version: 1.0 
#Date: 2007-07-13 13:30:37 
#Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem 
cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) 
cs(Referer) cs-host sc-status 

[Tutor] C# style multi-line textbox in Python

2007-06-02 Thread Darren Williams
Hi all,

I'm completely new when it comes to Python so forgive me for asking a 
potentially very simple question.  Can C# style multi-line textboxes for 
user-input be scripted in Python?  Are there any other attributes that I can 
add to either input() or raw_input()?___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor