Re: [Tutor] How do I make Python read a string character by character?

2006-08-23 Thread Akash
On 8/24/06, Nathan Pinno <[EMAIL PROTECTED]> wrote: > How do I make Python read a string character by character? >>> str = 'string' >>> for i in range(0, len(str)): ... print str[i] ... s t r i n g just take care about the indentation. -- regards akash _

[Tutor] How do I make Python read a string character by character?

2006-08-23 Thread Nathan Pinno
Hey all,   How do I make Python read a string character by character?   Thanks, Nathan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] What's the invalid syntax?

2006-08-23 Thread John Fouhy
On 24/08/06, Nathan Pinno <[EMAIL PROTECTED]> wrote: > Sorry, but it only showed a text-box with the message "Invalid syntax!", > then highlighted the %. Ok, so that would be on this line, I guess? print "Guess ", %d1.0, "."(k) Well, that's where the syntax error is, sure enough. Your edito

Re: [Tutor] What's the invalid syntax?

2006-08-23 Thread Nathan Pinno
Sorry, but it only showed a text-box with the message "Invalid syntax!", then highlighted the %. HTH, Nathan Pinno - Original Message - From: "Alan Gauld" <[EMAIL PROTECTED]> To: "Nathan Pinno" <[EMAIL PROTECTED]>; "Tutor mailing list" Sent: Wednesday, August 23, 2006 10:10 PM Subject:

Re: [Tutor] What's the invalid syntax?

2006-08-23 Thread Alan Gauld
> What's the invalid syntax in the following code? Dunno, Where does Python think it is? In other words what does the error message/IDE say? Give us a clue Alan G. # Hurkle Hunt # This program is a game where you have to find a hurkle that the computer hides in

Re: [Tutor] What's the invalid syntax?

2006-08-23 Thread Bob Gailer
Nathan Pinno wrote: > What's the invalid syntax in the following code? Is this a test? Do you want to see how smart we are? Or are you really trying to find and correct the problems? If the latter please OH please do as we have requested MANY TIMES - post the traceback. I'm also concerned, consi

Re: [Tutor] Adding the current working directory to the Windows path

2006-08-23 Thread John Fouhy
On 24/08/06, Alan Gauld <[EMAIL PROTECTED]> wrote: > PATH is an environment variable and therefore changing it only > affects the current process environment. You need to change it > at source which used to be in AUTOEXEC.BAT but I don't think > that is the preferred place in Win2K/XP. To change t

Re: [Tutor] Adding the current working directory to the Windows path

2006-08-23 Thread Alan Gauld
> Is there a simple way to append the os.getcwd() to the windows path > statement? I've tried variations of > > def createDirectory(self): >os.system('PATH %%PATH%%;%s;'%(here)) # here = os.getcwd() > > but it doesn't seem to work. PATH is an environment variable and therefore changin

Re: [Tutor] What's the invalid syntax?

2006-08-23 Thread John Fouhy
What does the python interpreter tell you when you run the code? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] What's the invalid syntax?

2006-08-23 Thread Nathan Pinno
What's the invalid syntax in the following code?   # Hurkle Hunt# This program is a game where you have to find a hurkle that the computer hides in a grid.# Originally in Computer World pg. 70   import random   print "Hunt the Hurkle"printwhile 1:    ans = raw_input("Do you want to play a ga

Re: [Tutor] banners

2006-08-23 Thread John Fouhy
On 23/08/06, Juhász János <[EMAIL PROTECTED]> wrote: > I just played about this exercise and it has to be about spelling and not > about hardcoding, as It is more interestig to join banner characters into > the same line. I had a brief think about that as well. I think if I tried to code it, my a

Re: [Tutor] Adding the current working directory to the Windows path

2006-08-23 Thread Terry Carroll
On Wed, 23 Aug 2006, travis mcgee wrote: > Is there a simple way to append the os.getcwd() to the windows path > statement? I've tried variations of > > def createDirectory(self): > os.system('PATH %%PATH%%;%s;'%(here)) # here = os.getcwd() > > but it doesn't seem to work. I don't get

[Tutor] Adding the current working directory to the Windows path

2006-08-23 Thread travis mcgee
Is there a simple way to append the os.getcwd() to the windows path statement?  I've tried variations of def createDirectory(self):    os.system('PATH %%PATH%%;%s;'%(here)) # here = os.getcwd()but it doesn't seem to work.  I don't get an error in IDLE, but if I open a command prompt, the path d

Re: [Tutor] How to wrap this line of code?

2006-08-23 Thread Bob Gailer
Dick Moores wrote: > At 12:48 AM 8/23/2006, Alan Gauld wrote: > >> here's another thing to consider: >> >> Since its too long for your code its probably too long for your >> display too, so think about where you would like the line break >> to be on the final print. Put in a newline character t

Re: [Tutor] banners

2006-08-23 Thread Bob Gailer
Consider: charmap = """ A BBBCCC etc... A A B B C C D D A A BBB C D D A B B C C D D A A BBBCCC """ Which lets you enter each letter the way you want it to look. No need to laboriously translate that by hand into tuples. Let the compute

[Tutor] banners

2006-08-23 Thread Juhász János
Josip wrote: >>Write a Python program that spells out >>your name or nickname using special characters. I just played about this exercise and it has to be about spelling and not about hardcoding, as It is more interestig to join banner characters into the same line. DotMap = { 'P' : ('PPP

Re: [Tutor] How to wrap this line of code?

2006-08-23 Thread Dick Moores
At 12:48 AM 8/23/2006, Alan Gauld wrote: > here's another thing to consider: > >Since its too long for your code its probably too long for your >display too, so think about where you would like the line break >to be on the final print. Put in a newline character there and >put the line break there

Re: [Tutor] [whitelist] Re: os.path.walk

2006-08-23 Thread nimrodx
Thanks guys, I will have a go at both of the methods. Matt Alan Gauld wrote: >> Yes, that is the right way to do it and it will work fine. Something >> like >> >> class Walker(object): >> def walk(self, base): >>os.path.walk(base, self.callback, None) >> > > >> What happens is, when

Re: [Tutor] How to wrap this line of code?

2006-08-23 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote >I have this long print statement in a script: > > print "Initial integer of first sequence with number of terms of %d > or more was %s (%d)" % (length, intCommas(n_for_max_c), > n_for_max_c) > > It's one line of code, and too long. How can I wrap it so th

Re: [Tutor] How to use

2006-08-23 Thread Alan Gauld
"emman uel" <[EMAIL PROTECTED]> wrote >How to use this program? Which program? I assume since you wrote to the Pyhon tutor mailing list you mean some aspect of Python? Do you mean the installer that you download from the web site? - just double click and it will run and install Python on your sys

Re: [Tutor] How to wrap this line of code?

2006-08-23 Thread Bob Gailer
Dick Moores wrote: At 11:10 PM 8/22/2006, Bob Gailer wrote: Dick Moores wrote: I have this long print statement in a script: print "Initial integer of first sequence with number of terms of %d or more was %s (%d)" % (length, intCommas(n_for_max_c), n_for_max_c)