Re: [Tutor] IF statements

2008-10-06 Thread Alan Gauld

WM [EMAIL PROTECTED] wrote

to IF.  The code below was not written by me.  It is a copy/paste 
job from the tutor.  I do not have any idea what is going wrong.



 x = int(raw_input(Please enter an integer: ))
Please enter an integer: 42
 if x  0:
...  x = 0
...  print 'Negative changed to zero'
... elif x == 0:
...  print 'Zero'
... elif x == 1:
...  print 'Single'
... else:
...  print 'More'
...
More
12
SyntaxError: invalid syntax


It looks as if you maybe cut more than you intended?
Also I'm not sure about the ... prompts. I don't have 2.6 yet
so maybe its an enhancement to IDLE but notmally IDLE
doesn't print ... prompts. Did you cut n paste them too?
If so that would confuse IDLE.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 



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


Re: [Tutor] first call - newcomer

2008-10-06 Thread Alan Gauld


Anthony Smith [EMAIL PROTECTED] wrote


This is my first post - I will be brief...


Hi, welcome to tutor :-)


1.  A brief (but complete) description regarding the use of script
editor (I will be using command prompt in Windows), as:


Brief and Complete don;t normally go together!
If you are using IDLE then Danny yoo's intro is a good place to start.
The IDLE section of the Python web site has a more detailed run
through oof the faciilities.

a.  details about loading and saving programs (not in that 
order) and little
 specs about pathnames or other requirements (I will 
probably store all

 my little goodies in one folder or space).

As to paths:

PATH should be set to the folder where the Python interpreters live
PYTHONPATH should be set to include the folder where your code lives

2.  I have been unable to locate the gizmo in the literature to get 
ascii codes

in python.


chr(n) is the function you need
ord(c) is the one in the opposite direction

but...


   was PRINT VAL(A$) or something.


Python will generally figure out what you want to print without
explicit conversions, certainly fewer than you will be used to
from the early BASIC versions.

assign a number to a word (using a simple algorhythm that will 
give a
specific number to every word).  Other stuff is pretty easy to 
find with
the book and on-line literature.  I will need to get an ascii 
code out of
a string (whose content is not known to the programmer, as 
raw_input).
Then to assign, I will need the actual list with assigned 
numbers.


OK, You lost me here.
Can you give an example of what the data would look like?

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 



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


Re: [Tutor] IF Statements

2008-10-06 Thread Rajeev Nair
also i believe the first line can also be written as 'x = input('enter
...') instead of using x=int(raw_input('..') . use raw_input for
string and just input for integer.



regards

rajeev

On Mon, Oct 6, 2008 at 3:30 PM, [EMAIL PROTECTED] wrote:

 Send Tutor mailing list submissions to
tutor@python.org

 To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tutor
 or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]

 You can reach the person managing the list at
[EMAIL PROTECTED]

 When replying, please edit your Subject line so it is more specific
 than Re: Contents of Tutor digest...


 Today's Topics:

   1. Re: Tutor Digest, Vol 56, Issue 22 (Lie Ryan)
   2. Re: Tutor Digest, Vol 56, Issue 22 (Lie Ryan)
   3. Re: IF statements (Alan Gauld)
   4. Re: first call - newcomer (Alan Gauld)


 --

 Message: 1
 Date: Mon, 06 Oct 2008 12:46:49 +0700
 From: Lie Ryan [EMAIL PROTECTED]
 Subject: Re: [Tutor] Tutor Digest, Vol 56, Issue 22
 To: tutor@python.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain

 On Mon, 2008-10-06 at 05:32 +0200, [EMAIL PROTECTED] wrote:
 
  Message: 8
  Date: Sun, 5 Oct 2008 20:27:39 -0700
  From: Anthony Smith [EMAIL PROTECTED]
  Subject: [Tutor] first call - newcomer
  To: tutor@python.org
  Message-ID: [EMAIL PROTECTED]
  Content-Type: text/plain; charset=iso-8859-1
 
 
  This is my first post - I will be brief...
 
  One:  I have programmed before - but it has been DECADES...so just a
  few simple queries:
 
  1.  A brief (but complete) description regarding the use of script
  editor (I will be using

 Your script editor can be any plain text-editing tools, Notepad could
 do.

   command prompt in Windows), as:
 
   a.  details about loading and saving programs (not in that
  order) and little
specs about pathnames or other requirements (I will
  probably store all
my little goodies in one folder or space).

 Pathnames is free, you can name your program anything your OS allows for
 a file. A convention is to name the script ending with .py/.pyw
 extension (command-line script/GUI script), although python doesn't
 complain if it is not in those extension (in Windows, the extension is
 associated with the interpreter). Calling a program from command line is
 done like this:

 python filename.py

That should get me going ... a book and manual by my side should
  suffice for
 the rest - - - except for one thing:

  2.  I have been unable to locate the gizmo in the literature to get
  ascii codes
  in python.  In the old days, it was a list of 256 (or so)
  characters that
  represented all keyboard symbols (A equalled 36; B equalled 37; et
  cetera).
 To assign a value, you used Let A$ = ASC (36) where A$ was a
  variable
  and 36 was the ASCII value for 'A'.  I believe the reverse of this
  process
  was PRINT VAL(A$) or something.  I want to play with a program
  that will
 assign a number to a word (using a simple algorhythm that will give
  a
  specific number to every word).  Other stuff is pretty easy to
  find with
  the book and on-line literature.  I will need to get an ascii code
  out of
   a string (whose content is not known to the programmer, as
  raw_input).
  Then to assign, I will need the actual list with assigned numbers.

 a = ord('A')
 b = chr(36)

 -- read on the help file: Built-in Functions

  You will be giving me probably the only boost I will need!  I will be
  available later on,
  if I want to take part in the ask/answer system here.



 --

 Message: 2
 Date: Mon, 06 Oct 2008 12:46:49 +0700
 From: Lie Ryan [EMAIL PROTECTED]
 Subject: Re: [Tutor] Tutor Digest, Vol 56, Issue 22
 To: tutor@python.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain

 On Mon, 2008-10-06 at 05:32 +0200, [EMAIL PROTECTED] wrote:
 
  Message: 8
  Date: Sun, 5 Oct 2008 20:27:39 -0700
  From: Anthony Smith [EMAIL PROTECTED]
  Subject: [Tutor] first call - newcomer
  To: tutor@python.org
  Message-ID: [EMAIL PROTECTED]
  Content-Type: text/plain; charset=iso-8859-1
 
 
  This is my first post - I will be brief...
 
  One:  I have programmed before - but it has been DECADES...so just a
  few simple queries:
 
  1.  A brief (but complete) description regarding the use of script
  editor (I will be using

 Your script editor can be any plain text-editing tools, Notepad could
 do.

   command prompt in Windows), as:
 
   a.  details about loading and saving programs (not in that
  order) and little
specs about pathnames or other requirements (I will
  probably store all
my little goodies in one folder or space).

 Pathnames is free, you can name your program anything your OS allows for
 a file. A convention is to name 

Re: [Tutor] IF statements

2008-10-06 Thread Kent Johnson
On Sun, Oct 5, 2008 at 10:51 PM, WM [EMAIL PROTECTED] wrote:
 I used to do Basic and enjoyed it.  Someone said Python was a vastly better
 language than Visual Basic, which I considered playing with.  So I sought to
 give it a go but struck a sticking point very early.
 I am now going through the Python tutorial.  All went well until I came to
 IF.  The code below was not written by me.  It is a copy/paste job from the
 tutor.  I do not have any idea what is going wrong.

 IDLE 2.6 

 x = int(raw_input(Please enter an integer: ))
 Please enter an integer: 42
 if x  0:
 ...  x = 0
 ...  print 'Negative changed to zero'
 ... elif x == 0:
 ...  print 'Zero'
 ... elif x == 1:
 ...  print 'Single'
 ... else:
 ...  print 'More'
 ...
 More
 12
 SyntaxError: invalid syntax


Did you paste the  and ... or were they printed by the interpreter?
Examples often show the entire contents of a session in the
interpreter, including the  and ... prompts. When you enter the
example yourself you should not include them. Also Please enter an
integer:  is output from the program and 42 is user input to the
program, you should not paste either of them.

Where did the 12 come from? It looks like interpreter output but there
is nothing preceding it that would print a 12.

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


[Tutor] Delete file before function ends

2008-10-06 Thread Adrian Greyling
Greetings all,

Not sure if this is possible, but I'll ask anyway.  Below is a code snippet
that creates my problem...  What I'd like to do, is create a plain text
file, use the associated program to open said textfile, (using os.startfile)
and after the associated program has what it needs to open the file and then
of course, has the current focus, I'd like to delete the text file in the
background, so to speak.  (Please assume that the program doesn't lock
'mytextfile.xyz' when it opens it.)

What happens with the code snippet below, is that it doesn't really start
the second program until the function is finished.  I tried using
time.sleep() in between the os.startfile() and os.remove(), but it just
delays opening 'mytextfile.xyz' and actually deletes the file before my
second program can open it up.  Any way around this??

path = c:\MyFolder\mytextfile.xyz
#bunch of stuff here to create 'mytextfile.xyz
os.startfile(path)
os.remove(path)


Thanks everyone,
Adrian
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Delete file before function ends

2008-10-06 Thread Tim Golden

Adrian Greyling wrote:

Not sure if this is possible, but I'll ask anyway.  Below is a code snippet
that creates my problem...  What I'd like to do, is create a plain text
file, use the associated program to open said textfile, (using os.startfile)
and after the associated program has what it needs to open the file and then
of course, has the current focus, I'd like to delete the text file in the
background, so to speak.  (Please assume that the program doesn't lock
'mytextfile.xyz' when it opens it.)

What happens with the code snippet below, is that it doesn't really start
the second program until the function is finished.  I tried using
time.sleep() in between the os.startfile() and os.remove(), but it just
delays opening 'mytextfile.xyz' and actually deletes the file before my
second program can open it up.  Any way around this??

path = c:\MyFolder\mytextfile.xyz
#bunch of stuff here to create 'mytextfile.xyz
os.startfile(path)
os.remove(path)



Strange. I would have expected the opposite effect: the
os.startfile runs (notepad, or whatever) but doesn't
return control until it's complete.

In any case, try the following snippet. The sleep is
needed because the app probably won't launch in time
to get there before the remove does.

code
import os
import subprocess
import time

FILENAME = os.path.abspath (temp.txt)
f = open (FILENAME, w)
f.write (blah blah)
f.close ()

subprocess.Popen ([FILENAME], shell=True)
time.sleep (1.0)
os.remove (FILENAME)

/code

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


Re: [Tutor] Delete file before function ends

2008-10-06 Thread Tim Golden

Adrian Greyling wrote:


path = c:\MyFolder\mytextfile.xyz



BTW, I hope you're using raw strings in your
real code, or else you're going to come a
cropper one day when a filename begins with t.

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


Re: [Tutor] IF Statements

2008-10-06 Thread Alan Gauld


Rajeev Nair [EMAIL PROTECTED] wrote
also i believe the first line can also be written as 'x = 
input('enter
...') instead of using x=int(raw_input('..') . use raw_input 
for

string and just input for integer.


No, use input() only in very special circumstances or when
experimenting for personal use only.

Use int(raw_input()) for all production code. It is much safer.

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 



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


[Tutor] Fwd: IF statements

2008-10-06 Thread Kent Johnson
Forwarding to the list...

-- Forwarded message --
From: Thomas Walch [EMAIL PROTECTED]
Date: Mon, Oct 6, 2008 at 10:35 AM
Subject: Re: [Tutor] IF statements
To: Kent Johnson [EMAIL PROTECTED]


Entering the code in the interpreter I could not find an issue. No
error at all. Might be that you launched some things in the
interpreter by mistake?

Anyhow, I put the code in an editor and saved it as xxx.py. Again no
error while running the program.

Just try again. Might be different then. I suggest to download SPE:

http://developer.berlios.de/project/showfiles.php?group_id=4161

and try to run it as file too.

Have a nice time

Thomas

Kent Johnson schrieb:

 On Sun, Oct 5, 2008 at 10:51 PM, WM [EMAIL PROTECTED] wrote:


 I used to do Basic and enjoyed it.  Someone said Python was a vastly better
 language than Visual Basic, which I considered playing with.  So I sought to
 give it a go but struck a sticking point very early.
 I am now going through the Python tutorial.  All went well until I came to
 IF.  The code below was not written by me.  It is a copy/paste job from the
 tutor.  I do not have any idea what is going wrong.

 IDLE 2.6 


 x = int(raw_input(Please enter an integer: ))


 Please enter an integer: 42


 if x  0:


 ...  x = 0
 ...  print 'Negative changed to zero'
 ... elif x == 0:
 ...  print 'Zero'
 ... elif x == 1:
 ...  print 'Single'
 ... else:
 ...  print 'More'
 ...
 More
 12
 SyntaxError: invalid syntax


 Did you paste the  and ... or were they printed by the interpreter?
 Examples often show the entire contents of a session in the
 interpreter, including the  and ... prompts. When you enter the
 example yourself you should not include them. Also Please enter an
 integer:  is output from the program and 42 is user input to the
 program, you should not paste either of them.

 Where did the 12 come from? It looks like interpreter output but there
 is nothing preceding it that would print a 12.

 Kent
 ___
 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] IF Statements

2008-10-06 Thread Kent Johnson
On Mon, Oct 6, 2008 at 7:24 AM, Rajeev Nair [EMAIL PROTECTED] wrote:
 also i believe the first line can also be written as 'x = input('enter
 ...') instead of using x=int(raw_input('..') . use raw_input for
 string and just input for integer.

Yes, although that is not really recommended, this has been discussed
very recently.

Also, please don't include the entire digest in your reply!

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


Re: [Tutor] Delete file before function ends

2008-10-06 Thread Alan Gauld


Adrian Greyling [EMAIL PROTECTED] wrote

that creates my problem...  What I'd like to do, is create a plain 
text
file, use the associated program to open said textfile, (using 
os.startfile)
and after the associated program has what it needs to open the file 
and then

of course, has the current focus, I'd like to delete the text file


Thats potentially going to cause the associated program to crash
but assuming you know what you are doing there...


What happens with the code snippet below, is that it doesn't start
the second program until the function is finished.


Correct, that's what you asked it to do :-)

time.sleep() in between the os.startfile() and os.remove(), but it 
just
delays opening 'mytextfile.xyz' and actually deletes the file before 
my

second program can open it up.


Really? That shouldn't happen!


path = c:\MyFolder\mytextfile.xyz


You probably want to either use forward slashes or put
an r in front of the quotes, otherwise Python will treat
the \ as an escape character...


#bunch of stuff here to create 'mytextfile.xyz
os.startfile(path)
os.remove(path)


If you want the remove to run in parallel with the startfile
you probably need to use threads to start the application
in one thread and then pause and then delete the file in
the other thread.

Alan 



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


Re: [Tutor] Delete file before function ends

2008-10-06 Thread Adrian Greyling
Thanks for the input folks. Sadly, Tim's suggestion yields the same results
as I was getting previously.  My second program very graciously tells me
that the file I'm trying to open doesn't exist.  Like the code snippet I
posted, the timer.sleep(x) line just waits the 'x' seconds until opening
'mytextfile.xyz, instead of opening it, and then waiting 'x' seconds to
delete the file.
Sorry about naming the path to my file so poorly!!  I'm a little more
careful in my programs!  I'm a newbie and I was more concerned about an
understandable question!

As a newbie, Alan, I was kinda scared you'd say that threads were the
answer here!  (It sounds like someone is going to get sucked into a worm
hole or something...)  Looks like the next class in my Python education is
going to be Threads 101...

Thanks for all the input, I might even be learning something!

Warmest regards,
Adrian




On Mon, Oct 6, 2008 at 1:31 PM, Alan Gauld [EMAIL PROTECTED]wrote:


 Adrian Greyling [EMAIL PROTECTED] wrote

  that creates my problem...  What I'd like to do, is create a plain text
 file, use the associated program to open said textfile, (using
 os.startfile)
 and after the associated program has what it needs to open the file and
 then
 of course, has the current focus, I'd like to delete the text file


 Thats potentially going to cause the associated program to crash
 but assuming you know what you are doing there...

  What happens with the code snippet below, is that it doesn't start
 the second program until the function is finished.


 Correct, that's what you asked it to do :-)

  time.sleep() in between the os.startfile() and os.remove(), but it just
 delays opening 'mytextfile.xyz' and actually deletes the file before my
 second program can open it up.


 Really? That shouldn't happen!

  path = c:\MyFolder\mytextfile.xyz


 You probably want to either use forward slashes or put
 an r in front of the quotes, otherwise Python will treat
 the \ as an escape character...

  #bunch of stuff here to create 'mytextfile.xyz
 os.startfile(path)
 os.remove(path)


 If you want the remove to run in parallel with the startfile
 you probably need to use threads to start the application
 in one thread and then pause and then delete the file in
 the other thread.

 Alan

 ___
 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] Delete file before function ends

2008-10-06 Thread Steve Willoughby
On Mon, Oct 06, 2008 at 02:15:06PM -0400, Adrian Greyling wrote:
 As a newbie, Alan, I was kinda scared you'd say that threads were the
 answer here!  (It sounds like someone is going to get sucked into a worm
 hole or something...)  Looks like the next class in my Python education is
 going to be Threads 101...

Threads are one approach, but if you aren't ready to jump into them,
that's not the only way to solve your problem.  However, please understand
that your application is trying to do something that's a bit more advanced
than the newbie level.  Any time you need to synchronize the operation
of multiple programs, there are complications and platform dependencies
involved that may not be as simple as you first think.

One natural, but naive, approach is to simply drop in a delay loop 
or call to time.sleep() to have the parent program wait long enough
for the child program to have done what it needs to do.  The problem
is you are only guessing how long is long enough, and will probably
be wrong enough of the time to be a problem.  

You need to work out some way to have the parent program wait for
a definite signal that the child is finished before moving forward.
That could be to use a subprocess invocation method which guarantees
the child will complete before it returns.  Or it could be that you
watch for an artifact created by the child, or wait for the child
process (or thread) to exit, or any of several other things.

Browse through the subprocess module for some hints of things you 
can try.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Delete file before function ends

2008-10-06 Thread W W
What OS are you using, Adrian? On WinXP, this worked fine:

import os

def files():
os.startfile('myfile.txt')
os.remove('myfile.txt')

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


Re: [Tutor] Delete file before function ends

2008-10-06 Thread Adrian Greyling
I'll take a peek at the subprocess docs Steve, and see if I can learn
something there...  Thanks for the suggestion!

I'm using WinXP as well Wayne..  Not too sure why yours works, and mine
doesn't..  I'll revisit what I'm doing and also check into Steve's
suggestion.
Adrian





On Mon, Oct 6, 2008 at 2:30 PM, W W [EMAIL PROTECTED] wrote:

 What OS are you using, Adrian? On WinXP, this worked fine:

 import os

 def files():
 os.startfile('myfile.txt')
 os.remove('myfile.txt')

 -Wayne

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


Re: [Tutor] Read a random record in dictionary object from csv module reader?

2008-10-06 Thread Kent Johnson
On Mon, Oct 6, 2008 at 3:32 PM, xbmuncher [EMAIL PROTECTED] wrote:
 import csv
 reader = csv.DictReader(open(test_csv.csv, r))

You should open the file with mode 'rb'

 reader is not an actual dictionary from my understanding.. so I don't know
 how to access properties like the 'total items' in the dictionary
 I want to be able to extract a random dictionary entry from the csv file,
 how can I do this by using the csv reader module? If I can't, then show me a
 better way to do it then..


reader is not a dictionary at all; it is a factory for dictionaries.
It produces a new dict for each line in the input file. Given your
code above, and assuming that the first line of the CSV file contains
field names, you can say
for d in reader:
  # d is a dict mapping field names to value for one line in the input file.

If you want all the items in a list, you could say
all_items = list(reader)

Then len(all_items) is the number of items in the dictionary and
random.choice(all_items) would give a randomly selected item dict.

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


[Tutor] Help Python String Search

2008-10-06 Thread Deitemeyer, Adam R
Hello,
 
I'm a beginner Python user and I have simple python issue I can't seem
to solve.  I want to do a truth test on a string to see if a another
string is contained within it.  I found that typically the re module has
the methods to accomplish this.  However, every string I'm searching
begins with a metacharacter.  For example: if the string '*I need *help'
contains the word 'help' then true, else false..  Any advice you can
provide would be great. 
 
Thanks,
Adam
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Using the curses module (or a better solution)

2008-10-06 Thread Tony Cappellini
I'm maintaining a framework of tests which are run on a diskless Linux
client, in character mode (no graphical desktop).

The tests often print out a lot of info, which scrolls off the screen.

I'd like to add a 1-2 line no-scroll-area at the top of the screen, so as to
print a message which indicates the progress of the current test.

I am thinking about using the Python curses module for this, unless someone
would suggest an alternative solution, although I'm not sure if the curses
module
has this non-scroll area capability.

http://www.amk.ca/python/howto/curses/

Ideally I'd like something which works on Windows  Linux, but since the
test environment on Linux is non-graphical, packages like WxPython can't be
used.


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


[Tutor] IF statements-1

2008-10-06 Thread WM

TO THIS ORIGINAL POST I GOT SIX REPLIES.

WM wrote:
  I used to do Basic and enjoyed it.  Someone said Python was a vastly
  better language than Visual Basic, which I considered playing with.  So
  I sought to give it a go but struck a sticking point very early.
  I am now going through the Python tutorial.  All went well until I came
  to IF.  The code below was not written by me.  It is a copy/paste job
  from the tutor.  I do not have any idea what is going wrong.
 
  IDLE 2.6 
 
  x = int(raw_input(Please enter an integer: ))
  Please enter an integer: 42
  if x  0:
  ...  x = 0
  ...  print 'Negative changed to zero'
  ... elif x == 0:
  ...  print 'Zero'
  ... elif x == 1:
  ...  print 'Single'
  ... else:
  ...  print 'More'
  ...
  More
  12
  SyntaxError: invalid syntax
 

IS THIS THE WAY TO ANSWER?  OR SHOULD I DO INDIVIDUAL REPLIES?

JOHNSON 1
The copy above is exactly from the book, via COPY  PASTE, from IDLE26 
thru More.

I keyed in the 12 to generate the error message.

JOHNSON 2
All that was running was IDLE from the desktop and the tutor from the 
Python.Org site.
I will not do the down-load right now as I want the tutor to work with 
the program with no tinkering.


JOHNSON 3
I did not understand Nair's reply, so I didn't follow thru there.
What is the entire digest and how do I not include it?

LANE
I keyed in 12  Enter.  The rest is copy/paste.
I will key the text into Notepad then run it, as you suggest.

GAULD
Not so.  You can check on the tutor, the code stops at 'More'.
It's funny about the dots, they were in the tutor but not in IDLE, 
although the indents were the same.  Then, in the e-mil, there they 
were.  IDLE hides dots?  What do I know?


NAIR
Your post to me starts, also I believe...  It looks like the front end 
got truncated.

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


Re: [Tutor] Help Python String Search

2008-10-06 Thread Kent Johnson
On Mon, Oct 6, 2008 at 5:37 PM, Deitemeyer, Adam R
[EMAIL PROTECTED] wrote:
 Hello,

 I'm a beginner Python user and I have simple python issue I can't seem to
 solve.  I want to do a truth test on a string to see if a another string is
 contained within it.  I found that typically the re module has the methods
 to accomplish this.  However, every string I'm searching begins with a
 metacharacter.  For example: if the string '*I need *help' contains the word
 'help' then true, else false..

This would only be an issue with regexes if the pattern you are
searching for contained metacharacters. Then you would escape them.
But John's approach is simpler in this case.

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


Re: [Tutor] Using the curses module (or a better solution)

2008-10-06 Thread Kent Johnson
On Mon, Oct 6, 2008 at 6:58 PM, Tony Cappellini [EMAIL PROTECTED] wrote:


 I'm maintaining a framework of tests which are run on a diskless Linux
 client, in character mode (no graphical desktop).

 The tests often print out a lot of info, which scrolls off the screen.

 I'd like to add a 1-2 line no-scroll-area at the top of the screen, so as to
 print a message which indicates the progress of the current test.

 I am thinking about using the Python curses module for this, unless someone
 would suggest an alternative solution,

See the recent discussion of urwid for discussion of a similar problem.
http://thread.gmane.org/gmane.comp.python.tutor/50500/

If the tests are based on unittest or assert, you might be interested
in nose; it suppresses output for tests that pass.
http://code.google.com/p/python-nose/wiki/NoseFeatures

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


[Tutor] IF statment 2

2008-10-06 Thread WM
Hey, guys, forgive me; I can't help being a fool.  Just now I READ the 
program and it worked perfectly!  42 is more than 1 so it printed 
More.  My error was that I imagined there was a loop where no loop 
could be.  Oh, me; oh, my.

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


Re: [Tutor] IF statements-1

2008-10-06 Thread Kent Johnson
On Mon, Oct 6, 2008 at 9:48 PM, WM [EMAIL PROTECTED] wrote:
 TO THIS ORIGINAL POST I GOT SIX REPLIES.

 IS THIS THE WAY TO ANSWER?  OR SHOULD I DO INDIVIDUAL REPLIES?

Either way is OK. It helps to quote a bit of the post to which you are
replying, for context. And please don't use all caps, it is
interpreted as shouting. And you seem to be a bit off in your
attributions...

 JOHNSON 1
 The copy above is exactly from the book, via COPY  PASTE, from IDLE26 thru
 More.
 I keyed in the 12 to generate the error message.

You can't just paste the examples verbatim from the tutorial. The
examples are showing you both the text that you type and the output of
the interpreter. In particular the  and ... are output and should
not be typed or pasted in.


 JOHNSON 3
 I did not understand Nair's reply, so I didn't follow thru there.
 What is the entire digest and how do I not include it?

That was a note to Rajeev, who included a lot of extraneous text in his reply.

Did you start at the beginning of the tutorial or are you starting
with section 4?

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


Re: [Tutor] Using the curses module (or a better solution)

2008-10-06 Thread Tony Cappellini
 See the recent discussion of urwid for discussion of a similar problem.
 http://thread.gmane.org/gmane.comp.python.tutor/50500/
This looks interesting.

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