Re: [Tutor] how to print a message backwards

2009-09-24 Thread Sander Sweers
2009/9/24 ALAN GAULD : >> print message[::-1] > > Yes, the for loop doing one character at a time will be much > slower than using a slice. The slice is more pythonic but less general. > A reverse loop is something that is often needed in programming > solutions so it's useful to know how to do it

Re: [Tutor] how to print a message backwards

2009-09-24 Thread Serdar Tumgoren
> Does anyone have an advanced topic on slicing where the :: notation is > explained? > You should find plenty by googling for "python slice step sequence" Here are a few with links to further resources: http://www.python.org/doc/2.3/whatsnew/section-slices.html http://stackoverflow.com/questions

[Tutor] Novice qustion

2009-09-24 Thread george fragos
 Hi all Pythons!  I'm new to Python and this List!  I'm reading Hetland's "Beginning Python" and I tried to test myself an example the book provides in 59:  width = input('Please enter width: ') price_width = 10 item_width = width - price_width header_format = '%-*s%*s' format        = '%-*s%*.

Re: [Tutor] Novice qustion

2009-09-24 Thread Oxymoron
On Thu, Sep 24, 2009 at 10:15 PM, george fragos wrote: > print format % (item_width, 'Cantaloupes', price_width, 1.92) > print format % (item_width, 'Dried Apricots (16 gr)' price_width, 8) > Notice the line before (works) and after (doesn't work - as the interpreter pointed out), how do you sepa

Re: [Tutor] Novice qustion

2009-09-24 Thread Serdar Tumgoren
>>  File "test.py", line 18 >>    print format % (item_width, 'Dried Apricots (16 gr)' price_width, 8) >>                                                                   ^ >> SyntaxError: invalid syntax Oxymoron has pointed you in the right direction. After you fix that error, however, you'll get

Re: [Tutor] Executing a command from a specific directory

2009-09-24 Thread Ansuman Dash
Hi Kurt, Sorry for the late reply. My problem is resolved. Instead of "subprocess.Popen", I used "subprocess.call". Thanks all for your replies. AD On Fri, Sep 18, 2009 at 8:05 PM, Kurt Bendl wrote: > Hello, > > On Sep 18, 2009, at 5:16 AM, Ansuman Dash wrote: > > I have written it like th

Re: [Tutor] Novice qustion

2009-09-24 Thread george fragos
2009/9/24 Oxymoron : >> print format % (item_width, 'Cantaloupes', price_width, 1.92) >> print format % (item_width, 'Dried Apricots (16 gr)' price_width, 8) > > > Notice the line before (works) and after (doesn't work - as the interpreter > pointed out), how do you separate items in a tuple? :-) >

[Tutor] code improvement

2009-09-24 Thread Norman Khine
Hello, I have this function in my class: http://paste.lisp.org/display/87659 Is there a better method to write the last bit of the code. Thanks Norman ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.py

[Tutor] Unknown reason for error.

2009-09-24 Thread Corey Richardson
Hello, python tutors, its Corey. Anyway, I'm getting a syntax error for an unknown reason. Here is my code...     name = raw_input("What is your name?") print "Hello, ", name wellness = raw_input("How are you?") if wellness != "Good":     if wellness != "Well":     if wellness != "Fine":   

Re: [Tutor] code improvement

2009-09-24 Thread Kent Johnson
On Thu, Sep 24, 2009 at 2:12 PM, Norman Khine wrote: > Hello, > I have this function in my class: > > http://paste.lisp.org/display/87659 > > Is there a better method to write the last bit of the code. Better in what way? What are these things? What is resource? Some context would be helpful, I s

Re: [Tutor] Unknown reason for error.

2009-09-24 Thread Robert Berman
Cory, It would be helpful for us to see the code and the exact error message(s). Would you copy your code and the errors directly to either your post or your code to one of the posting pages such as www.pastebin.org so we can see your code exactly how you have written it. Robert On Thu, 2009

Re: [Tutor] Unknown reason for error.

2009-09-24 Thread greg whittier
On Thu, Sep 24, 2009 at 2:15 PM, Corey Richardson wrote: > Hello, python tutors, its Corey. > Anyway, I'm getting a syntax error for an unknown reason. Here is my > code... > name = raw_input("What is your name?") > print "Hello, ", name > wellness = raw_input("How are you?") > if wellness !=

Re: [Tutor] Unknown reason for error.

2009-09-24 Thread christopher . henk
> Hello, python tutors, its Corey. Hi, Corey. > candyNumber = raw_input("How many candies do you want? :" You dropped a closing parenthesis in the line above. Having the syntax error occur one line up from where it is indicated is not uncommon. Another thing as long as we are here, in

[Tutor] invalid syntax (reply)

2009-09-24 Thread Corey Richardson
Robert, that is my code. The error? "Theres an error in your program : invalid syntax" Closing the parenthesis helped that one, but my else statement is not working...heres the code chunk... if wellness != "Good": elif wellness != "Well": elif wellness != "Fine": print "Oh,

Re: [Tutor] invalid syntax (reply)

2009-09-24 Thread Brett Wilkins
if wellness != "Good": elif wellness != "Well": elif wellness != "Fine": print "Oh, I'm sorry you are not feeling well. I guessed correct, right?" I think the problem is the elif's and the indents... elif is 'else if', and should be at the same indentation level as the prev

Re: [Tutor] invalid syntax (reply)

2009-09-24 Thread christopher . henk
tutor-bounces+christopher.henk=allisontransmission@python.org wrote on 09/24/2009 05:43:24 PM: > Robert, that is my code. The error? "Theres an error in your program : > invalid syntax" > Closing the parenthesis helped that one, but my else statement is not > working...heres the code chunk.

Re: [Tutor] python win32 drive mapping help

2009-09-24 Thread Vineet Kothari
Thanks a lot Vishwajeet & everyone else who replied. This is great I am glad now its working & I knew I was missing the module but somehow didn't know from where I would get that. But glad everything is working fine now. This is great community :) -- Regards, Vineet Kothari http://www.vineetkotha

Re: [Tutor] how to print a message backwards

2009-09-24 Thread Sander Sweers
On Thu, 2009-09-24 at 08:07 -0400, Serdar Tumgoren wrote: > You should find plenty by googling for "python slice step sequence" Now that I know what to look for I went to the online python docs [1] and tried to find where it has been documented. Unfortunately all the slicing examples I found do

Re: [Tutor] invalid syntax (reply)

2009-09-24 Thread Alan Gauld
"Corey Richardson" wrote Closing the parenthesis helped that one, but my else statement is not working...heres the code chunk... if wellness != "Good": elif wellness != "Well": elif wellness != "Fine": print "Oh, I'm sorry you are not feeling well. I guessed correct, rig

Re: [Tutor] python win32 drive mapping help

2009-09-24 Thread Vineet Kothari
Can you also help me out with the way to delete the mapped drive I know in command line it is > net use [DRIVE:] /delete > but I am unable to figure out how I can do it from python Since I am trying to make sure that the drive name I am giving in my code: > import win32net > win32net.NetUseAdd(

Re: [Tutor] how to print a message backwards

2009-09-24 Thread Kent Johnson
On Thu, Sep 24, 2009 at 7:02 PM, Sander Sweers wrote: > Now that I know what to look for I went to the online python docs [1] > and tried to find where it has been documented. > > Unfortunately all the slicing examples I found do not even mention that > there is optional step value. See footnote

[Tutor] Anyone with Experience Using WinTV Capture Cards?

2009-09-24 Thread Wayne Watson
A friend is looking for some help with how to use Python to access a WinTV (Go Plus) capture card, and how to display an image from it. Is there some facility that might help him, or does anyone have experience with such use that might suggest sources? Win XP OS. Any general methods for dealing

Re: [Tutor] code improvement

2009-09-24 Thread Norman Khine
On Thu, Sep 24, 2009 at 10:25 PM, Kent Johnson wrote: > On Thu, Sep 24, 2009 at 2:12 PM, Norman Khine wrote: >> Hello, >> I have this function in my class: >> >> http://paste.lisp.org/display/87659 >> >> Is there a better method to write the last bit of the code. > > Better in what way? What are