Re: [Tutor] Multi-line comments?
You could use Kwrite and select the to be commented part and use the keys Ctrl + D and to uncomment Ctrl + Shift + D. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Running Python on Gentoo
Yes, I have the same problem with running python scripts from console in Debian, the line "#! /usr/bin/python" doesn't help. I have to type "python script.py" in order to run the script.py file. On 7/26/07, Greg Lindstrom <[EMAIL PROTECTED]> wrote: > > Hello, > I am running python 2.4.2 on Gentoo Unix and am having problems running > programs. I have a script, hello.py as such: > > #! /usr/bin/python > print 'hello, world' > > that I save and add executable permission. Then at the prompt I type in.. > > $ ./hello.py > -bash: ./hello.py: /usr/bin/python: bad interpreter: Permission denied > > If I type > $ python hello.py > I get "hello, world" as expected. > > I was hoping that the "shabang" would have the script execute. Am I > missing something? Can you help me? BTW, when I type /usr/bin/python > at the prompt I get the python interpreter, so at least that's working. > > Thanks, > --greg > > ___ > 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] Books with exercises and problems to solve
Hello all, so long i have been learning python with two books 1) Official tutorial by Guido Van Rossum and 2) Pythong Programming: An Introduction to Computer Science by John M. Zelle and like them a lot as the first one gives a lot of explanations but without any exercises, but the second one has a lot of exercises to do which I like. I would like to know if anyone can recommend a book like the second one with a lot of exercises to do and problems to solve, not just the explanations for concurrent and also further study. Thanks a lot. P.S.= I am new both to Python and Programming too. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Books with exercises and problems to solve
thanks a lot for your help On 8/7/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > Khamid Nurdiev wrote: > > Hello all, > > so long i have been learning python with two books 1) Official tutorial > > by Guido Van Rossum and 2) Pythong Programming: An Introduction to > > Computer Science by John M. Zelle and like them a lot as the first one > > gives a lot of explanations but without any exercises, but the second > > one has a lot of exercises to do which I like. I would like to know if > > anyone can recommend a book like the second one with a lot of exercises > > to do and problems to solve, not just the explanations for concurrent > > and also further study. > > "Python Programming for the absolute beginner" is written for people > with no prior programming experience and includes exercises. > > Wesley Chun's "Core Python Programming" includes exercises. > > Kent > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Decoding
Hello All, I am currently learning python with the book "Python programming: An introduction to CS" by John M. Zelle and have come the section where he speaks of encoding messages. Currently the basic snippet looks like this: def dec(): > > import string > > message=raw_input("Enter the message to decode: ") > > result='' > > for x in string.split(message): > > result=result+chr(eval(x)) > > return result > > > > print dec() > > it works fine as expected but I want to enter the message as a variable like: a='12 34 84 39 122' and when the function dec() invoked, i would just enter "a" as an input and thus have changed the code a little bit but it is not working. def dec(): > > import string > > message=raw_input("Enter the message to decode: ") > > a=message[1:-1] > > result='' > > for x in string.split(a): > > result=result+chr(eval(x)) > > return result > > > > print dec() > > > Have tried many ways, i don't want to write them all here as they will take too much space. None of them work. maybe you guys know some way out? or where is it going wrong? Thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Decoding
Thanks, it really works. On 8/13/07, bhaaluu <[EMAIL PROTECTED]> wrote: > > Greetings, > > Disclaimer: I'm a Python Noob, > so use the code snippets > in this post, at your own risk! > > Is this what you're looking for? > > def dec(a): > import string > result='' > for x in string.split(a): > result=result+chr(eval(x)) > return result > > print dec(raw_input("Enter the message to decode: ")) > > I took raw_input() out of the dec() function and pass the string to the > function > as an argument. Or, to assign it to a variable, then pass it: > > a=raw_input("Enter the message to decode: ") > print dec(a) > > Or, if you want to read the code from a file on disk called code.txt > which has the following code in it: > 65 66 67 68 > > fin=open('code.txt','r) > a = fin.read() > fin.close() > print dec(a) > > ABCD > -- > bhaaluu at gmail dot com > > On 8/12/07, Khamid Nurdiev <[EMAIL PROTECTED]> wrote: > > Hello All, > > I am currently learning python with the book "Python programming: An > introduction to CS" by John M. Zelle and have come the section where he > speaks of encoding messages. Currently the basic snippet looks like this: > > > > > > > > > > > def dec(): > > > > import string > > > > message=raw_input("Enter the message to decode: ") > > > > result='' > > > > for x in string.split(message): > > > > result=result+chr(eval(x)) > > > > return result > > > > > > > > print dec() > > > > > > > > > it works fine as expected but I want to enter the message as a variable > like: > > a='12 34 84 39 122' > > and when the function dec() invoked, i would just enter "a" as an input > and thus have changed the code a little bit but it is not working. > > > > > > > > > > > def dec(): > > > > import string > > > > message=raw_input("Enter the message to decode: ") > > > > a=message[1:-1] > > > > result='' > > > > for x in string.split(a): > > > > result=result+chr(eval(x)) > > > > return result > > > > > > > > print dec() > > > > > > > > > > > Have tried many ways, i don't want to write them all here as they will > take too much space. None of them work. maybe you guys know some way out? or > where is it going wrong? > > > > Thanks > > > > ___ > > 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] Security [Was: Re: Decoding]
It is Good that you have the book because i have a few questions concerning the books again. This book by M. Zelle is getting really difficult shortly after that section (also as i see the examples are getting fewer) but it was easy till that part, so the question is: is it to me or is the rest of the book indeed explained not well(not like the beginning parts)?. Having heard the recommendations on books for beginners i have ordered the book "Core Python Programming" by Wesley Chun, so comparing those two books which one is more suitable (recommended) for a beginner to both python and programming? Here in our local library, the first edition of "Core python programming" is available so i guess i will use it till I receive the second edition, but i think it might take like a month, if not more till it gets to where i live. Is there much difference between the first and second editions? And also one more book, i haven't ordered it yet, is the "Python from novice to professional" by Magnus Lie Hetland, is it worth ordering and studying for a complete noob? thanks for your answers. On 8/13/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > bhaaluu wrote: > > > The original poster posted a post with the following function: > > def dec(): > > import string > > message=raw_input("Enter the message to decode: ") > > result='' > > for x in string.split(message): > > result=result+chr(eval(x)) > > return result > > > > print dec() > > which is from the book: > > "Python programming: An introduction to CS" by John M. Zelle. > > > > As a Python Noob, I'm obviously ignorant of most of the Python > > language, but I wonder why the author of a book would include > > a function that is a "gaping security hole," when the int() function > > would do the job just as nicely, and without the security concerns? > > I can't answer for Mr Zelle. Looking at the book, he introduces int(), > float() and long() shortly after the section containing the above example. > > > > Of course, I don't know what context the snippet is in because I > > don't have a copy of the book in question. But as a Python Noob, > > I really do appreciate your heads-up about eval(), and I have it > > red-flagged as a 'gaping security' concern, and will use it with > > extreme caution in the future. =) > > Good. There is almost always a better way to accomplish a task than to > use eval(). > > > Now for MY question: Besides eval(), are there other functions that > > should be 'red-flagged' as well? I just haven't been around Python > > long enough yet to become familiar with all of the Standard Library. > > Correct me if I'm wrong, but with 29 keywords, and over 176 library > > functions, Python weighs-in at over 200 Standard "objects"? > > Anything where user input is executed as code is a security hole and > should never be opened to untrusted users. > eval() > exec > execfile() > > come to mind. > > 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] Python Book Recommendations [Was:[Re: Security]]
This was really helpful. My message was sent just to find the book exactly like Alan's "Tutor" for the start. And can proceed to other books after it. Programming isn't for everyone! Until you find out whether or not > > it's for you, don't spend hundreds and thousands of dollars on > > computer programming books! =) > > It was just a try to find the proper book for a beginner and also when asked lots of people here recommended it for the beginner. As for me, I just followed the mind of more experienced people like the patient follows the advice of a doctor :-) Anyways thanks a lot, it is really nice that there is such a mailing list and such willing people to help. On 8/14/07, bhaaluu <[EMAIL PROTECTED]> wrote: > > Greetings, > > The only Python Books I have are the ones that are freely > available for download from the Internet. Here is the list: > > Learning to Program (by Alan Gauld - a Tutor on this list.) > http://www.freenetpages.co.uk/hp/alan.gauld/index.htm > This book is also available for purchase in dead-tree form. > > How To Think Like a Computer Scientist: Learning with Python > http://ibiblio.org/obp/thinkCS/python/english2e/html/index.html > > Dive Into Python > http://www.diveintopython.org/ > > A Byte of Python > http://swaroopch.info/text/Byte_of_Python:Main_Page > > Python Documentation > http://docs.python.org/index.html > > Thinking in Python > http://mindview.net/Books/TIPython > > Text Processing in Python > http://gnosis.cx/TPiP/ > > Your best bet may be the "Learning to Program" book by Alan Gauld. > Also there are a ton of tutorials on the Internet, many of which will > get you up to speed with the basic stuff in a hurry. > > On 8/13/07, Khamid Nurdiev <[EMAIL PROTECTED]> wrote: > > It is Good that you have the book because i have a few questions > concerning > > the books again. This book by M. Zelle is getting really difficult > shortly > > after that section (also as i see the examples are getting fewer) but it > was > > easy till that part, so the question is: is it to me or is the rest of > the > > book indeed explained not well(not like the beginning parts)?. > > I call that the "Chapter 3 Syndrome." > They start out the book holding your hand, and explaining > everything nicely... then around Chapter 3 the author gets > tired of going so slowly, and the pace picks up and leaves me > behind. =) > > > Having heard > > the recommendations on books for beginners i have ordered the book "Core > > Python Programming" by Wesley Chun, so comparing those two books which > one > > is more suitable (recommended) for a beginner to both python and > > programming? > Programming isn't for everyone! Until you find out whether or notit's for > you, don't spend hundreds and thousands of dollars on computer programming > books! =) > Here in our local library, the first edition of "Core python programming" > > is available so i guess i will use it till I receive the second edition, > but > > i think it might take like a month, if not more till it gets to where i > > live. Is there much difference between the first and second editions? > And > > also one more book, i haven't ordered it yet, is the "Python from novice > to > > professional" by Magnus Lie Hetland, is it worth ordering and studying > for a > > complete noob? > > I think your local library is a great idea for checking out programming > books! Also, look into the Inter-library loan system for books that might > not be in your library branch. Most libraries can borrow books for you > from another branch within the system, or even from out-of-state. > > Another resource is the local used-book stores. $40-$50 programming > books for $4-$5. They may have some highlighting or underlining, > but that doesn't usually make the content suffer. Often they'll > have the CD or floppy disk in the back cover. > > Finally, if you do find a computer programming book that you > think is the Philosopher's Stone, and you can't live without it, > check all the used-book stores that sell online at: > > http://used.addall.com > > > > > thanks for your answers. > > > > You're welcome. =) > -- > bhaaluu at gmail dot com > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Book Recommendations [Was:[Re: Security]]
I see it now, thanks for the detailed explanation. On 8/14/07, wesley chun <[EMAIL PROTECTED]> wrote: > > > > Having heard > > > the recommendations on books for beginners i have ordered the book > "Core > > > Python Programming" by Wesley Chun, so comparing those two books which > one > > > is more suitable (recommended) for a beginner to both python and > > > programming? > > if you are new to programming, then perhaps Core Python isn't the best > book for you. the target audience is for those who already know how > to program but want to learn Python as quickly and as in-depth as > possible. this is not to say that you cannot benefit from the book as > a newbie, but that it just isn't written directly for you. > > if you are a pure beginner, then: > > - alan's materials work great (the book is somewhat out-of-date but > the tutorial is contemporary): > http://www.freenetpages.co.uk/hp/alan.gauld > > - "how to think like a computer scientist" is also a good choice > http://www.ibiblio.org/obp/thinkCS/python/english2e/html > > - if you have to have a book, then i've heard good things about > dawson's "absolute beginner" book: > http://www.courseptr.com/ptr_detail.cfm?isbn=1-59863-112-8 > > - magnus hetland has TWO online tutorials... the 'instant python' one > is more for programmers but for newbies, you should read the 'instant > hacking' one: > http://hetland.org/writing/instant-hacking.html > > the zelle book is mainly for an undergraduate introduction to computer > science, so if you want to learn programming but not get the "science" > part of it yet, then you also need to look elsewhere. i suspect this > (the CS part) is what begins in chapter 3. :-) > > > > I think your local library is a great idea for checking out programming > > books! Also, look into the Inter-library loan system for books that > might > > not be in your library branch. Most libraries can borrow books for you > > from another branch within the system, or even from out-of-state. > > i second this recommendation. > > > > Another resource is the local used-book stores. $40-$50 programming > > books for $4-$5. They may have some highlighting or underlining, > > but that doesn't usually make the content suffer. Often they'll > > have the CD or floppy disk in the back cover. > > you can also check out http://half.com as well as eBay for popular books. > > hope this helps! > -- wesley > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > "Core Python Programming", Prentice Hall, (c)2007,2001 > http://corepython.com > > wesley.j.chun :: wescpy-at-gmail.com > python training and technical consulting > cyberweb.consulting : silicon valley, ca > http://cyberwebconsulting.com > ___ > 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] Security [Was: Re: Decoding]
I guess i will start out with your tutorial, hope it won't get as difficult as the previous one :-) thanks On 8/14/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > > "Khamid Nurdiev" <[EMAIL PROTECTED]> wrote > > > This book by M. Zelle is getting really difficult shortly > > after that section > > I can't comment on the specific book but unfortunately its > a common phenomenon that "beginner" books start of easy > then suddenly get much harder. This is partly because it is > very hard for an experienced programmer to think like a true > beginner, there is just so much we take for granted as obvious. > > > the recommendations on books for beginners i have ordered the book > > "Core > > Python Programming" by Wesley Chun, so comparing those two books > > which one > > is more suitable (recommended) for a beginner to both python and > > programming? > > Wes' book is a very good book on Python, personally I think it might > be quite fast paced and detailed for a beginner to programming but > there are plenty tutorials on the web for that, including mine! :-) > > > Here in our local library, the first edition of "Core python > > programming" > > is available so i guess i will use it till I receive the second > > edition, ... > > . Is there much difference between the first and second editions? > > In the detauil yes but not in the fundamental principles. Especially > the early chapters seem pretty similar. Mind you I've only looked > at the second edition in depth, I've only seen the first edition in > book > stores... > > > also one more book, i haven't ordered it yet, is the "Python from > > novice to > > professional" by Magnus Lie Hetland, is it worth ordering and > > studying for a > > complete noob? > > No idea but you really don't want too many introductory texts, > you will rarely look at them once you learn how to program. > (Wes' book is a good exception since he has a lot of "under the > covers" > stuff about how python works which even experienced pythonistas can > use) > > 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 > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor