Re: [Tutor] Python 2.3.5 question
Hello. I am Roman. I bought this book call Python Programming for the Absolute Beginner which I am and after I downloaded Python 2.3.5 from their CD, I opened IDLE, typed "Game Over" and nothing happened. What do I do? Please, help. I don't understand any of the programming jargon. Please talk simple to me. With great appreciation, Roman rspl...@earthlink.net EarthLink Revolves Around You.___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What is this an example of (and how can i use it?)
On Wed, Sep 23, 2009 at 12:58 AM, kevin parks wrote: > It appears it is not so impenetrable as i initially > though. Well iterators > aren't maybe, but generator do look tricky. So interators iterate over > lists, tuples, strings, dictionaries > and any data type that is iterable, and generators are ways to make new > iterables? Exactly. Kent ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python 2.3.5 question
On Wed, 2009-09-23 at 01:10 -0700, rspl...@earthlink.net wrote: > Hello. I am Roman. I bought this book call Python Programming for the > Absolute Beginner which I am and after I downloaded Python 2.3.5 from > their CD, I opened IDLE, typed "Game Over" and nothing happened. What > do I do? Please, help. I don't understand any of the programming > jargon. Please talk simple to me. > With great appreciation, > Roman I think you need to re-read the book. You need to type: print "Game Over" Python then outputs: Game Over As for the jargon, you'll have to get used to it. Start with the next section of the book, 'Learning the Jargon'. HTH, Tim Bowden ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] how to print a message backwards
#Message backward printer message=input('Enter your message: ') for i in range(len(message),0,-1): print(message) This is the code which I have written. All it does is count the number of letters starting from backwards. The proper code should so something like this: Enter your message: Hi. My name is Ali Sina Your message in backwards: aniS ilA si eman yM .iH ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to print a message backwards
Try reading up on sequences and slicing. They offer a very elegant solution to your (homework?) problem. http://docs.python.org/tutorial/introduction.html#strings ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to print a message backwards
> http://docs.python.org/tutorial/introduction.html#strings > The below page is a better introduction to sequences: http://effbot.org/zone/python-list.htm It uses lists, but the lessons on slicing also apply to strings (which are a type of sequence). HTH! Serdar ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python 2.3.5 question
Hello. I am Roman. Hi Roman. I bought this book call Python Programming for the Absolute Beginner which I am and after I downloaded Python 2.3.5 from their CD, I opened IDLE, typed "Game Over" and nothing happened. Why did you do that? Did the book say to do it? Are you sure that's what it said? In programming you have to be very careful over details of spelling, spacing and punctuation. I don't understand any of the programming jargon. Please talk simple to me. We will try, you do need to learn the jargon but that's what the book should teach you. If you don't understand something in the book just ask here. You might also try looking at the equivalent topic in my web tutor which is also aimed at complete beginners... When you do post questions here its best to reference where in the book you are reading. Also paste in any code and error messages you have - the whole error message not just the last line. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to print a message backwards
"Ali Sina" wrote #Message backward printer message=input('Enter your message: ') for i in range(len(message),0,-1): print(message) This is the code which I have written. All it does is count the number of letters starting from backwards. Correct, plus it prints the original message each time. So obviously you need to print something else! If you are counting one letter at a time maybe you should print one letter at a time? However/... Others have given you a big hint about using slicing instead so I'll leave you to research that yourself. -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python 2.3.5 question
>> Hello. I am Roman. I bought this book call Python Programming for >> the Absolute Beginner which I am and after I downloaded Python 2.3.5 >> from their CD, I opened IDLE, typed "Game Over" and nothing >> happened. What do I do? Please, help. I don't understand any of the >> programming jargon. Please talk simple to me. With great >> appreciation, >> Roman That jargon is a bit of a hurdle at the start. It's like trying to succeed at the game where some asks, Can you repeat exactly what I tell you? Sure. OK, Three blind mice. That's easy, "Three blind mice." Nope. Wanna try again? Sure. OK. Three blind mice. That's what you said last time. Yep. Three blind mice! Nope. AARG!! And eventually you realize that "OK" is part of what you had to say, too. It was hard (by hearing alone) to tell what were the words to repeat and what were conversational filler. Any good book on programming is going to use some way to tell you exactly what to type. Usually they do that by changing the font. They usually start the book by telling you what to look for. If you are just getting started, *don't skip that part of the book*! And pay extra close attention to the exactly what they tell you to type. OK? Give it another try. Give it another try? Nope. But you said, "Give it another try!" Nope, I said "OK? Give it another try." :-) /c ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to print a message backwards
Is there a significant difference in speed, style, or any pythonesque reasoning between Alan's solution and print message[::-1] Thanks for any information, Robert On Wed, 2009-09-23 at 18:51 +0100, Alan Gauld wrote: > "Ali Sina" wrote > > #Message backward printer > message=input('Enter your message: ') > > for i in range(len(message),0,-1): > print(message) > > > > This is the code which I have written. > > All it does is count the number of letters starting from backwards. > > Correct, plus it prints the original message each time. > So obviously you need to print something else! If you are counting > one letter at a time maybe you should print one letter at a time? > > However/... > Others have given you a big hint about using slicing instead > so I'll leave you to research that yourself. > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] ODBC SQL Server Question
Hi, Thanks you guys for the replies and thanks Kent for the explanation, and yes, this: self.cursor.execute("SELECT CUSTID FROM Stories WHERE NAME= ?", (name, )) using the comma did make it work. On Fri, Sep 18, 2009 at 3:40 PM, Jeff Johnson wrote: > Thanks for the clarification Kent! > > > Kent Johnson wrote: > >> On Fri, Sep 18, 2009 at 2:14 PM, Jeff Johnson >> wrote: >> >>> Kent: >>> >>> How about this: >>> self.cursor.execute("SELECT CUSTID FROM Stories WHERE NAME = '%s'" % >>> (name, >>> )) >>> >> >> No, that has the same result as your original. For example, >> In [3]: name = "Kent'; drop table Stories;--" >> >> In [4]: "SELECT CUSTID FROM Stories WHERE NAME = '%s'" % (name, ) >> Out[4]: "SELECT CUSTID FROM Stories WHERE NAME = 'Kent'; drop table >> Stories;--'" >> >> Oops. >> >> Question, does execute know to substitute the question mark with name? >>> self.cursor.execute("SELECT CUSTID FROM Stories WHERE NAME= ?", (name, )) >>> >> >> Yes, and it will correctly quote name according to the conventions of >> the database in use. (Note that not all DB-API implementations use ? >> as the placeholder; check the docs for the db you are using.) >> >> Kent >> > > -- > Jeff > > Jeff Johnson > j...@dcsoftware.com > Phoenix Python User Group - sunpigg...@googlegroups.com > -- Cheers, Krissy --- Testing the waters is always fun... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Switching from 2.3 to 2.6
Hi guys, I'm getting this error after I tried to switch from python 2.3 to 2.6. I tried to look online for what it means, but I can't find any good explanation. Do any of you guys have any idea what's causing it and what it means? C:\Python26\lib\site-packages\win32\lib\dbi.py:13: DeprecationWarning: dbi module is obsolete, code should now use native python datetime and buffer/memoryview objects DeprecationWarning) -- Cheers, Krissy --- Testing the waters is always fun... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to print a message backwards
On 9/23/2009 7:22 AM Ali Sina said... #Message backward printer message=input('Enter your message: ') for i in range(len(message),0,-1): print(message) This is the code which I have written. All it does is count the number of letters starting from backwards. The proper code should so something like this: Enter your message: Hi. My name is Ali Sina Your message in backwards: aniS ilA si eman yM .iH There's also a reversed keyword introduced in python 2.4. Emile ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Switching from 2.3 to 2.6
On Thu, Sep 24, 2009 at 5:46 AM, Kristina Ambert wrote: > Hi guys, > I'm getting this error after I tried to switch from python 2.3 to 2.6. I > tried to look online for what it means, but I can't find any good > explanation. > Do any of you guys have any idea what's causing it and what it means? > C:\Python26\lib\site-packages\win32\lib\dbi.py:13: DeprecationWarning: dbi > module is obsolete, code should now use native python datetime and > buffer/memoryview objects > DeprecationWarning) Sounds like the dbi module has been deprecated: i.e. it's out of date, and contains ugly code that will eventually be removed. Therefore, you should change the parts of your code that use it. If you read the error message, it tells you which up-to-date/better alternatives you should be using instead. n.b. this is general information; I have no knowledge of the specific modules/objects listed. HTH, benno. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to print a message backwards
> Is there a significant difference in speed, style, or any pythonesque > reasoning between Alan's solution and > 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 for the general case. But where the data can be sliced that will be faster and more concise. Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how to print a message backwards
Thank you for the clear explanation. Robert On Wed, 2009-09-23 at 23:40 +, ALAN GAULD wrote: > > Is there a significant difference in speed, style, or any pythonesque > > reasoning between Alan's solution and > > 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 for the general case. > But where the data can be sliced that will be faster and more > concise. > > Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor