Re: [Tutor] [Python-ideas] Terminology for "earthshattering" [was: Add from __experimental__ import bla]
On Friday 02 September 2011 14:19:55 Christopher King wrote: > it just sounds awesome. ??? To me it sounds like alphabet soup! Which is, of course, what, I would argue, it is. ;-) Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] SOLVED and thank you was: Re: meaning of % in: if n % x == 0:
This was meant to go to the list. I did notrealise that it had not until I looked at the list just now and couln't see my reply. Sorry, "delegbede", and sorry list. On Wednesday 31 August 2011 Lisi wrote: > ?? If either n or x or both were 0, and % were the same thing as *, the > statement would be true, but from the context I don't think that % does > mean the same as *, because * appears very soon after in the same fragment > of code. On Wednesday 31 August 2011 20:59:05 delegb...@dudupay.com wrote: > % is a remainder division. I think its called modulo. Yes! Thank you. :-) I ought to have been able to guess that it was modulo - shows that I am indeed becoming slow-witted. :-( Thank you, all three of you, for such fast and helpful responses. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] meaning of % in: if n % x == 0:
?? If either n or x or both were 0, and % were the same thing as *, the statement would be true, but from the context I don't think that % does mean the same as *, because * appears very soon after in the same fragment of code. Lisi I'm sorry I am making such heavy weather of all this. Blame 2 things: anno domini and an exaggerated (obsessive) need to understand language. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 90, Issue 97
On Tuesday 30 August 2011 02:21:15 Steven D'Aprano wrote: > Heh, well different people find different approaches useful. To coin a cliché, it would be a dull world if we were all the same. :-) Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
On Monday 29 August 2011 19:02:29 Alan Gauld wrote: > To be fair, in the paper edition of my tutor I do use a Games framework > as a second case-study. I then use the framework to build a number > guessing game and a Hangman (and a Mastermind on the CD)... Now, I knew there was a reason I decided to use the on-line version. ;-) I just didn't realise how wise my decision was. Anyhow, those games strike me as being reasonably innocuous - and fairly untypical of what computer games seem normally to be about. > Games are popular with many beginners especially hobbyists rather > than corporate types :-). Yes, I agree. I also agree that many (male) youngsters would like it. But statistically women don't like computer games (and yes, I know some do, but among women they are statistically in a minority). So using games for _all_ programming books strikes me as being almost sexist. It is after all, a good way to keep women out! ;-) And what have you got against corporate types??? ;-) Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 90, Issue 97
On Monday 29 August 2011 18:01:44 Cranky Frankie wrote: > I'm sorry you were offended by my posts. If others were as well let me > know and I'll unsubscribe immediately. Post in the singular. I could not, and can not, I'm afraid, see the point in writing such a long panegyric about Python to a list of Python users. And you do seem to have gone wa OT over that particular book, which I bought and found unusable. But it didn't _offend_ me, it just struck me as spam. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
On Monday 29 August 2011 16:45:17 Lisi wrote: > Is it just me, or is this a blatant plug for a specific book, and is it > therefore Spam? Given that remark, I ought not to have included the full text in my reply. I apologise to our spam filters. :-( Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Intro
Is it just me, or is this a blatant plug for a specific book, and is it therefore Spam? For what it is worth, I hate all those games. Alan seems to use address books (anyhow initially). Now I can see the point in that. Lisi On Monday 29 August 2011 16:26:55 Cranky Frankie wrote: > Hi Python tutor listers, as an intro I'll repost what I sent to my > Linux groups, since one of their members turned me on to you: > > > > Before Borders imploded I'd joined their club so they'd send me 50% > coupons now and then. One afternoon last year I was in the store > browsing the computer books and this Python book caught my eye. I knew > very little about Python but I knew it had a good rep and I love Monty > Python so I bought the book then put in on the shelf. Only recently > did I get around to reading it and I only wish I'd done so sooner, > it's that good. > > The book is "Python Programming for the Absolute Beginner, Third > Edition" by Michael Dawson, Course Technology, ISBN-13 > 978-1-4354-5500-9, published in 2010. He presumes you know nothing > about programming and then uses simple computer games to demonstrate > the power of Python. He starts with those text based games many of us > used to play, finishing off with GUI based games with music and > animation, and all the code is downloadable from the publisher's web > site. That's pretty good for a beginner book, I'd say. > > Python itself is a beautiful language. Because it uses indenting for > constructing programming blocks, not semi-colons or braces, the code > is inherently clean and crisp. More about Python: > > - it's easy to learn yet very powerful > - very concise and tight syntax > - comes with it's own IDE > - no compiling yet can create stand alone apps > - can be used for scripting or full blown applications > - runs on all the major OSs > - no variably type declarations, it can infer them > - lots of modules (pre-coded specific code routines) available > - can get productive quickly > - can code in a procedural or object-oriented style > > Here's the typical introductory "Hello World" program: > > print("Hello World") > > Doesn't get much simpler than that! > > He even gets into GUI programming, event driven design, sprites, etc. > For a book for a supposed absolute beginner I think that's amazing, > because I can see someone getting this even if they really have no > coding background. That's how clearly it's written and how clean and > clear the example code is. > > One more side benefit of this book: it contains the gentlest, easiest > to digest introduction to object-oriented programming I've ever seen, > and I read a lot of computer stuff. If you're an old-timer like me who > only studied procedural languages, this is about as easy an > introduction to the power and flexibility of O-O programming that you > will ever find. > > What I've been wanting to do for a long time is write an app that, > when my computer starts, displays a window with a quote of the day. > With this book I now have several ways to take my huge collected > quotes file, import it into arrays in a Python program, apply a random > function, and display a random quote each time I log on. That kind of > app is a natural for Python, but don't kid yourself - he actually > writes a space invaders type game using some game modules - and this > in a beginner book! Amazing. > > > This is a great book about a great language. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] One basic question about the Python's PID of Process object.
On Monday 29 August 2011 07:17:51 Han Guanghua wrote: > 2. Second question: When I changed the os.getpid() to os.getppid() or > self. _pid, the Python’s interpreter generates some error message like > “Customer object has no attribute ‘_pid’”. > > I'm very much a beginner myself, but I am sure that someone will correct me if I am wrong. Should it not be self.pid rather than self._pid? Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Still stuck - but a bit further on.
On Sunday 28 August 2011 16:20:45 Alan Gauld wrote: > > Notice the space at the start of the string? > The stored entry is keyed on "Lisi" the search was for " Lisi" > which doesn't exist. I thought that I had tried that, but I obviously hadn't. I clearly needed that break! Thanks, Alan and Steven. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Still stuck - but a bit further on.
Sorry, everybody. I am still having problems with this script - tho' it now runs correctly nearly to the end! Here is the whole script: #! /usr/bin/python # create an empty address book dictionary AddressBook = {} # read entries till an empty string print name = raw_input("Type the Name - leave blank to finish") while name != "": entry = raw_input("Type the Street, Town, Phone. Leave blank to finish") AddressBook[name] = entry name = raw_input("Type the Name - leave blank to finish") # now ask for one to display name = raw_input("Which name to display?(blank to finish)") while name !="": print name, AddressBook[name] name = raw_input("Which name to display?(blank to finish)") I started with: lisi@Tux:/usr/local/bin$ AddressBook Type the Name - leave blank to finishLisi Type the Street, Town, Phone. Leave blank to finishth, rc, 123457 Type the Name - leave blank to finish Which name to display?(blank to finish) Lisi Lisi Traceback (most recent call last): File "/usr/local/bin/AddressBook", line 17, in print name, AddressBook[name] KeyError: ' Lisi' I have tried various other words besides Lisi, each one less probable than its predecessor. I am getting nowhere. The error may well be somewhere else again, but I can't see where. :-( Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Can't find error :-(
On Sunday 28 August 2011 13:01:38 Peter Otten wrote: > Lisi wrote: > > Here is the error message: > > /usr/local/bin/AddressBook: line 6: syntax error near unexpected token > > `(' /usr/local/bin/AddressBook: line 6: `name = raw_input("Type the Name > > - leave blank to finish")' > > > > (sorry KMail wrapped it.) > > > > Here is what I typed: > > name = raw_input("Type the Name - leave blank to finish") > > > > Here is what I was copying: > > name = raw_input("Type the Name - leave blank to finish") > > > > Help!! All three are copied and pasted from their relevant places to > > eliminate mis-copying at this stage. What have I miscopied?? The > > original and my copy look to me *exactly* the same. > > That's an error message by your shell. You made your script executable, but > forgot to add something like > > #!/usr/bin/env python > > as its first line. > > NB. it's quite common that an error originates before the place where the > interpreter complains; it would have been a good idea to post the five > lines before the explicitly erroneous one, too. Thanks to both. I opened up the file to try retyping the ", although I had in fact typed it - the copying and pasting was into the email to ensure that I did not introduce any errors at that stage. But looking at the file, I realised that I had forgotten my shebang line - and had put it right before I read this answer. I am very grateful to you both. I had realised that the error might be somewhere other than where it is indicated because Alan had already told me so - but had not understood that it could be, not only in a different place, but quite a way away. Not even when I put this right. So thanks for that, Peter, and thank you again, both of you. For future reference, how would I set about changing the encoding for just one character or file? I don't really want to change the encoding I use system wide. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Can't find error :-(
Here is the error message: /usr/local/bin/AddressBook: line 6: syntax error near unexpected token `(' /usr/local/bin/AddressBook: line 6: `name = raw_input("Type the Name - leave blank to finish")' (sorry KMail wrapped it.) Here is what I typed: name = raw_input("Type the Name - leave blank to finish") Here is what I was copying: name = raw_input("Type the Name - leave blank to finish") Help!! All three are copied and pasted from their relevant places to eliminate mis-copying at this stage. What have I miscopied?? The original and my copy look to me *exactly* the same. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Raw input query (?)
On Thursday 25 August 2011 15:17:04 Alan Gauld wrote: > On 25/08/11 10:46, Lisi wrote: > > I copied and ran the following script: > > > > multiplier = 12 > > > > for j in range(1,13): > > print "%d x %d = %d" %(j, multiplier, j*multiplier) > > > > That ran perfectly and gave me the 12 times table. > > > > I then decided that it would be fun to branch out and make teh > > script "universal", so I wrote and ran: > > > > print "Which times table do you want?" > > > > multiplier = raw_input () > > I seem to recognise that code :-) > > You will find if you fast-forward to the "talking to the user" topic > that we revisit the multiplication table doing exactly this. You will > find out what is missing there. :-) Thanks to all three of you for your input. I do now understand what is wrong, but can't work out how to put it right. I did as you suggested, Dave. But by the time I was able to get to my computer and read it, the others' replies had come in. So I ran it mainly to learn how to do it. And I am not entirely sure that I would have understood the result if I hadn't already known what it was meant to be saying!! I started to say that I would just have to wait, but on second thoughts I'll fast forward as suggested, and then go back to do the missing sections. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Raw input query (?)
I copied and ran the following script: multiplier = 12 for j in range(1,13): print "%d x %d = %d" %(j, multiplier, j*multiplier) That ran perfectly and gave me the 12 times table. I then decided that it would be fun to branch out and make teh script "universal", so I wrote and ran: print "Which times table do you want?" multiplier = raw_input () for j in range(1,13): print "%d x %d = %d" %(j, multiplier, j*multiplier) The j in range section of code is identical, but I now get: lisi@Tux:~/Python$ python multiplier.py Which times table do you want? 4 Traceback (most recent call last): File "multiplier.py", line 8, in print "%d x %d = %d" %(j, multiplier, j*multiplier) TypeError: int argument required lisi@Tux:~/Python$ What extra should I have done because the variable value came from the keyboard, and why is it different from the first example? Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Where is sys.py?
Thanks, Alan. Very helpful; tho' I probably need to gigest Steven's information before I fully digest yours. On Tuesday 23 August 2011 01:15:52 Alan Gauld wrote: > So sub-routine comers from the world of assembler programming and was > adopted by BASIC because BASIC was invented back in the 1960's when most > folks were used to assembler. So _that's_ why I understand it. It is many years since I did any programmimg at all, but way back before the ark I did a bit of programming in both Basic and machine code. (And I mean machine code, not assembler.) Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Where is sys.py?
Thanks, Steven, for an extremely helpful email. I _think_ that I have now grasped it; tho' teh proof of teh pudding is in the eating. :-/ On Monday 22 August 2011 19:55:02 Steven D'Aprano wrote: > Lisi wrote: [snip] > Are you using Windows or Linux or Mac? Linux Debian 6. > On my Linux system, I can look inside: > > /usr/lib/python2.5/ and on mine. > and see the Python modules. Thanks again, Steven. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Where is sys.py?
On Monday 22 August 2011 17:31:41 Alan Gauld wrote: > Now I'm confused. Yes, I'm afraid that _I_ was very confused. I am gradually getting the mess in my head disentangled. > There can be functions inside a module but not commands, they are > technically something different and only exist within the Python > interpreter itself. And you can access those functions from the module > after you have imported it. > > I'm not sure what you mean by an envelope though? > The module is the envelope... By "envelope" I meant container, because I was afraid of misusing the correct technical terms. I am still very confused by the terminology. Having been told that modules, functions and methods are just different names for the same thing, that commands are really also the same thing and having had them called yet a fifth thing in order "not to confuse you" (ouch!!) I am in a right muddle. What I am doing at the moment is trying to sort out the muddle in my own head. You have no idea what a relief it was to be told (by you Alan in your text) that a function is a sub-routine. I know what a sub-routine is! And I shall just go on asking questions until I have got the whole thing disentangled in my head. Sorry, everybody. (Unlearning something is much harder than learning it.) Alan, I did enjoy playing around with address books, which I can see have some point, instead of chasing bears, lollipops and flowers, or whatever it was. :-( So now, can anyone suggest an example of a module to look at? (Preferably with some subroutines inside).It is clearly NOT just another name for function or method. I imagine that there are some on the Internet? > And I don't understand the bit about the time taken for short routines? > Do you mean the time taken to access them in terms of typing time? Or in > terms of execution time? It is faster to import than the time it takes > to retype a function unless the function is only a simple expression. I hadn't actually counted the keystrokes. I stand corrected. But saving 6 keystrokes is still a fairly pointless thing to do. If several subroutines can be stored in a module and imported together, then that is quite another matter. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Where is sys.py?
On Monday 22 August 2011 15:09:45 Emile van Sebille wrote: > Actually, sys retains a reference to all imported modules in sys.modules > and that gives a pretty good idea of where stuff comes from(tm). :) [snip interesting file] Thanks, Emile. :-) Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Where is sys.py?
On Monday 22 August 2011 00:13:37 Steven D'Aprano wrote: > > The modules within it must surely be somewhere too. But since I can't > > find sys, I obviously can't find the modules. Again, I'd like to look at > > them. > > I don't understand what you mean by "modules within it". The problem may be that I have again failed to understand. As I understand it, I can, should I wish to do so, write and save a subroutine that I wish to reuse rather than write the same subroutine out multiple times. The book also says that one can import sys and then run the various commands within it. It also appears to say that sys is a file, and I thought that it said sys.py existed. Clearly, it didn't since it doesn't. Anyhow, I therefore thought - erroneously - that if there could be commands in sys, then it must be possible to store subroutines in some sort of "envelope" so that I could import the "envelope" and call the subroutines as I wanted them. Otherwise, storing short subroutines would appear to me to be a waste of time and effort. By the time one has imported the subroutine and then run it, and done this for every one of a number of short subroutines, it would be quicker and easier just to run them when needed. So I wanted to look at how Python itself does it, so that I could copy it. a) I am clearly barking up a non-existent tree and b) the sooner I forget completely about the text that I was working from (I am still turning over in my mind the exercise I got hung up on) and focus only on Alan's, the sooner I am going to make some kind of progress!! Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How have I transgressed??
Thanks for the reply, Emile. :-) On Sunday 21 August 2011 18:25:44 Emile van Sebille wrote: > The sender's email address is verified and those 'new to the list' get > this message -- do you have multiple email accounts Yes - but I consistently use the same one for this list, and have checked my recent emails, and all came from the same (correct) address. > or possibly typoed > in your email address on the message that evoked the 'new' response? No - I have checked. So long as it wasn't triggered by a misdemeanour - that was what I was worried about! I have my email client set twice over to be correct for this list. a) it knows that this is a list and what email address I want used for this list and b) I use the default address for this list. Oh - and c) I don't type the address - I just chose which one. I think that it must just remain one of life's little mysteries. :-/ Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] How have I transgressed??
I have just received the following.* In what way have I transgressed? I apologise to you all - but as I mentioned, I had been stuck for weeks and am running out of time. And I certainly tried to help myself - I just didn't succeed! Anyhow, if someone will tell me in what way I have transgressed, I'll try harder in future. Thanks, Lisi *Your message for tutor@python.org, the Python programming tutor list, has been received and is being delivered. This automated response is sent to those of you new to the Tutor list, to point out a few resources that can help with answering your own questions, or improve the chances of getting a useful answer from the other subscribers. If your question is something akin to: "I've just heard about Python, and it sounds great! Where can I find out more on how to program with Python?" or: "What's Python?" please read section 1 below. On the other hand, if your question is: "I've heard that Python is good for hacking -- I want to know more!" or "Can you teach me how to break into a computer with Python?" please read section 2 at the bottom of this email. Section 1: -- The most comprehensive overview of python.org help resources is at http://www.python.org/Help.html The Python FAQ is available at http://www.python.org/doc/FAQ.html and it has answers to many questions that people ask, possibly including your question. Another wealth of information and experience can be found via the python.org searches, at http://www.python.org/search/ There you'll find comprehensive, easy-to-use searches over the python.org web site and the Python newsgroup, comp.lang.python. Python has an online tutorial, available freely from http://www.python.org/doc/current/tutorial/index.html Finally, when you do send email to the Tutor list, be as clear as you can about the problem, including, when relevant, details like: - Precise error messages, including complete tracebacks - The hardware platform (available in the Python sys module as sys.platform) - The python version (sys.version) - The python search path (sys.path) In general, be specific about what was going on connected with the problem or what specific concept you're having difficulties with. The better the info you provide, the more likely the helpers will be able to glean the answer... There's a HOWTO that shows how to ask "smart" questions to technical folks: http://catb.org/~esr/faqs/smart-questions.html Although it is provocative, it does have some good points, and is an interesting read. Note that no one is paid to read the tutor list or provide answers, and most readers often have other work that demands their attention. Well-posed requests for help are usually answered fairly promptly, but occasionally a request slips by, so if you do not get a response with one or two working days (it's usually quicker than that), please feel free to send a followup, asking whether anyone is working on your question. Anyway, your message is being delivered to the Tutor list as this one is being sent. However, if your question was about as detailed as "Teach me how to program in Python", do not count on an answer -- this email contains all the information you need to start. Come back with a more precise question, and we'll be glad to help. Thanks! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Where is sys.py?
On Sunday 21 August 2011 12:57:50 Lisi wrote: > If sys.py is a file, it must be somewhere; but I can't find it. Where is > it? I would like to look at it. > > The modules within it must surely be somewhere too. But since I can't find > sys, I obviously can't find the modules. Again, I'd like to look at them. > > In case it is relevant, I am using Python 2.5.2 on Debian 5. Thanks, all three. At least I now know why I can't find it! Robert - I had already tried various combimations of whereis, python and sys, all to no avail. But I tried your command and looked at every directory and file under the results (and tehre were a lot)! Still to no avail - so I switched from my personal inbox to the Python one - and there we have the explanation. Thanks Peter and "xDog". Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Where is sys.py?
If sys.py is a file, it must be somewhere; but I can't find it. Where is it? I would like to look at it. The modules within it must surely be somewhere too. But since I can't find sys, I obviously can't find the modules. Again, I'd like to look at them. In case it is relevant, I am using Python 2.5.2 on Debian 5. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Modules and Python tutorial by S. Thurlow - opinions please
On Saturday 20 August 2011 23:53:53 Alan Gauld wrote: > On 20/08/11 15:25, Lisi wrote: > > ridiculous. I think that I understand how to write a basic function, but > > I can't work out how to save and call it. [snip] > There is a full worked example in the Functions and Modules > topic in my tutorial... Bless you, Alan. Not only is your description great, but it caused me to start to read your tutorial. Bingo. I think I now understand the conceptual problem I had at the core of this. You actually make it clear in your answer in this thread, but I was so bogged down that I didn't take it in. A function is a sub-routine and not a program. That's it. So simple and I have been stuck on this for weeks! Now to start again! When, of course, I may get stuck again. But I think next time I am stuck on something apparently trivial, I'll ask sooner. And the descriptions that you and Steven have given me of how to do it make a lot more sense than the ones I was struggling with. Heartfelt thanks to Alan and Steven. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Modules and Python tutorial by S. Thurlow - opinions please
Thanks, Steven. :-) I'll get back to this this evening. Lisi On Saturday 20 August 2011 16:51:07 Steven D'Aprano wrote: > Lisi wrote: > > I have got myself well and truly bogged down. I need to change the angle > > from which I am looking. I only have a short while left for now in which > > to make some sort of progress with Python. What do people think of: > > > > http://www.sthurlow.com/python/ > > > > Is it reasonably accurate and therefore useful? > > As far as I can tell after a lightning fast read of it (about three > minutes to skim a few of the lessons), it seems perfectly fine to me. > > [...] > > > To show you what I mean: > > How to save and run a bash script: > > Write your script > > save it in the normal manner > > chmod to x for everyone you want to be able to execute it. (E.g. where > > owner is root: perhaps 744) > > Either move the file into a directory on your path, or add the directory > > that the file is in to your path. > > It will now run. > > > > Can anyone point me to a similar set of basic instructions for Python > > modules?? > > More or less exactly the same, except you need a hash-bang line at the > top of the script so that the shell knows that it is Python and not a > shell script. So you can add a line like: > > #!/usr/bin/python > > at the VERY TOP of your script (it MUST be in the first line for the > shell to recognise it). > > (This is exactly the same practice for all scripting languages, > including Perl, Bash, Ruby, and many more... if the hash-bang line is > missing, the shell will try to execute the file with "sh".) > > > As an alternative, you can call the script from the shell prompt like this: > > > $ python path/to/my/script.py > > (naturally you don't type the $ that is just the shell prompt) > > > Finally, you can put your script somewhere in the PYTHONPATH and then > call it like this: > > > $ python -m script > > > Note that this way you leave the .py off the end -- you're not telling > Python to *run* a file, but to *import* a file, which happens to run it > as a side-effect. I don't recommend you use this technique until you're > more comfortable with Python. I mention it only for completeness. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Modules and Python tutorial by S. Thurlow - opinions please
I have got myself well and truly bogged down. I need to change the angle from which I am looking. I only have a short while left for now in which to make some sort of progress with Python. What do people think of: http://www.sthurlow.com/python/ Is it reasonably accurate and therefore useful? If not, or even in addition, what can people recommend for me to dig myself out of the quagmire? I am having difficulty with the "wrong" things. If statements, while or for loops etc. don't phase me. But I am stuck on something so trivial that it is ridiculous. I think that I understand how to write a basic function, but I can't work out how to save and call it. To show you what I mean: How to save and run a bash script: Write your script save it in the normal manner chmod to x for everyone you want to be able to execute it. (E.g. where owner is root: perhaps 744) Either move the file into a directory on your path, or add the directory that the file is in to your path. It will now run. Can anyone point me to a similar set of basic instructions for Python modules?? Thanks, Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] which version do i have and how do i change it
On Tuesday 16 August 2011 21:53:46 Jerry Hill wrote: > On Tue, Aug 16, 2011 at 4:35 PM, Lisi wrote: > > lisi@Tux:~$ aptitude why python > > i reportbug Depends python (>= 2.5) > > lisi@Tux:~$ > > Keep in mind that that command only shows you a single dependency > chain. Try again with "aptitude -v why python" to see all of the > dependencies. On my ubuntu 11.04 machine, that command produces over > 9000 lines of output, and over 800 distinct packages that depend on > python in one way or another. Thanks for that. Very illuminating and interesting. I hadn't come across that command before. (I tend to look things up in man aptitude rather than read it through.) But in my case it only served to illustrate that nothing of any real importance in my system depends on Python. In fact, not only were there no direct dependency chains leading to Python, since all of them had at least 2 "suggests" in the chain, the few things that did depend on Python, at the end of the chain, after the suggests, were mostly not installed, so would not have missed Python. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] which version do i have and how do i change it
On Tuesday 16 August 2011 17:06:42 Alan Gauld wrote: > My concern was that if they uninstalled 2.7 the default would revert to > 2.6 (or > whatever) and they might then be tempted to uninstall that too! Yes - mea culpa for not realising that. Mind you, if I had investigated my own system I would hardly have come to the conclusion that Python was essential. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] which version do i have and how do i change it
On Tuesday 16 August 2011 17:06:42 Alan Gauld wrote: > It can be hard to tell, sometimes distro designers just think something > is useful. lisi@Tux:~$ aptitude why python i reportbug Depends python (>= 2.5) lisi@Tux:~$ !! Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] which version do i have and how do i change it
On Tuesday 16 August 2011 09:05:44 Alan Gauld wrote: > You might need to ensure that you have at least 1 version of Python2 around > because a lot of Linux tools are still written in v2 and might break if you > uninstall all v2 versions... Thanks for that, Alan. I knew that I had Python 2 by default and did not have to install it, but had not queried why. I clearly should have. I should also, of course, check whether something is a dependancy of something else before suggesting its removal. :-( Luckily, if he used a package manager of any kind, it would have warned him that it is a dependancy of various packages. If it was already on the system , I wonder why the OP needed to install it? Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] which version do i have and how do i change it
On Tuesday 16 August 2011 00:48:08 Walter Prins wrote: > On 16 August 2011 00:43, Connor Merritt wrote: > > So i installed python 2.7.1 on my linux and i bought a book that requires > > python 3 so installed python 3, and i used terminal and typed in python > > -V and it said 2.7.1 how do i get it to be 3 (i tried deleting it but i > > couldn't what should i do?) > > Try > > python3 -V > > The default is probably still Python2 but that does not mean you can't use > Python explicitly. If you prefer to have Python 3 only, you could also uninstall Python 2.7.1. You do not say what version of what distro you are using, nor what method you used to install Python 2, so I can't be more explicit. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What's the difference between %s and %r?
On Saturday 23 July 2011 13:48:03 amt wrote: > Hello! I'm having troubles understanding what is the difference between %s > and %r(format characters). I did google and found something on > StackOverflow but I don't understand the explanation as it's not beginner > orientated. > > > Also, I have this code from learn python the hard way. Why at line 9 does > he uses %r? Why did he didn't wrote print "I said: %s." %x ? > > 1x = "There are %d types of people." % 10 > 2binary = "binary" > 3do_not = "don't" > 4y = "Those who know %s and those who %s." % (binary, do_not) > 5 > 6print x > 7print y > 8 > 9print "I said: %r." % x > 10 print "I also said: '%s'." % y > 11 > 12 hilarious = False > 13 joke_evaluation = "Isn't that joke so funny?! %r" > 14 > 15 print joke_evaluation % hilarious > 16 > 17 w = "This is the left side of..." > 18 e = "a string with a right side." > 19 > 20 print w + e > > > > Thanks in advance! I have recently worked through that exact question myself. And it isn't well explained. So - the simplistic answer, gleaned (hopefully not erroneously) from this list: s means a string, d means a number and r can be either or both. y has only words, so is a string, and x has a number (specifically referred to as d) and words, so needs r. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] little/big endian was Re: what is 'doubleword alignment'?
On Tuesday 19 July 2011 22:43:40 Alan Gauld wrote: > Growing to hate my Netbook keyboard more by the day! Attach another keyboard? (To keep life simple it would have to be usb, but you can even get a keyboard that will roll up for carrying. I have neither seen nor tried one, so it may be no good!) Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Good Book
On Monday 18 July 2011 09:26:51 Ryan wrote: > Dear All Pythonist, > > I'm strarting learn python programming and I have been found many resources > on it but I have a problem. I don't know, what is the best complete book > for new learner like me. > > I need your recommendation, thanks before . . . I am using Learn Python The Hard Way by Zed A Shaw; http://learnpythonthehardway.org/ It is basic - assumes no knowledge of programming at all and is easy to follow. But as a beginning beginner myself, I find that I do most of my actual learning from the marvellous people on this list, with help also from my local Linux User Group. The book provides the exercises and structure. But, as has been said, your choice will depend on your own style. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] what is 'doubleword alignment'?
On Saturday 16 July 2011 21:53:55 Albert-Jan Roskam wrote: > I know that the buffer is comprised of variables of 8-bytes, or multiples > thereof, each. Numeric variables are 8 bytes, char vars are at least 8 > bytes. For example, a 10-byte value is 'ceiled' to 18 bytes. This is done > with padding (spaces, I think). But the aligment part...? then wrote: > Got it already, I think. The word boundary of one chunk of information (in > my case 8 bytes) is aligned in the computer's memory such that the > boundary's address is a power of two. Sorry to be slow. Blame virtually no sleep last night ;-( But even were the power of two bit correct (and I see subsequently that it is not), how is 18 a power of two? Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hello World in Python without space
On Saturday 16 July 2011 03:15:12 Richard D. Moores wrote: > But that makes me wonder if there isn't a simpler way to do it with > Python -- to delete the contents of a file without deleting the file? Up to now, knowing no better ;-), I have opened the file in, or copied and pasted the contents of a file into, a word processor and turned on the non-printing characters. It is then easy to see extraneous spaces, empty lines etc. I then go back to the editor and do the revealed editing. Rough, ready and cobbled - but easy, and it works. ;-) If you use Windows and have no idea what I am talking about, I apologise. It is so long since I used Windows that I have forgotten much of what it can and cannot do; and I don't know whether it can do this. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] broken script - curiouser and curiouser
On Thursday 07 July 2011 15:36:06 Michael M Mason wrote: > Maybe you've been editing ex25 and then executing ex26. That'd get you the > same error in the same place over and over again. Doh! They do say that there is one born every minute. Thanks, Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] broken script - curiouser and curiouser
On Thursday 07 July 2011 15:42:12 Michael M Mason wrote: > > Maybe you've been editing ex25 and then executing ex26. That'd get you > > the same error in the same place over and over again. > > Looks like this might be it. In your earlier post the error reported is in > ex26:- > > : lisi@Tux:~/Python/LearnPythonTheHardWay$ python ex26.py > : File "ex26.py", line 10 > : def print_first_word(words) > : ^ > : SyntaxError: invalid syntax > : lisi@Tux:~/Python/LearnPythonTheHardWay$ Doh! Thank you , Michael. The book does say something along the lines of "If you are stuck, leave it, take a break and come back to it later". Still, at least I can learn from my mistakes. ;-) That is my story anyway, and I'm sticking to it. Many years ago, in the days of the ark, when men were real men, and programming meant writing strings of 0s and 1s and then shifting pins around a board, I once spent over two hours trying to discover what was wrong with my code in just one spot. At the end of the over 2 hours it finally dawned on me that my code was fine - the memory location for that particular pin was faulty. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python conundrum
Hi! :-) >From the book I am working from: A shortcut is to do your import like this: from ex25 import * Is this a new and wonderful meaning of the word "shortcut"? _Why_, _how_ is that a shortcut for: import ex25 when it has seven *more* characters (counting the spaces)? Or, put another way, twice as many words? :-/ It is obviously an alternative, but I just don't get that it is a shortcut. Thanks, Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] broken script - curiouser and curiouser
On Thursday 07 July 2011 10:21:59 Walter Prins wrote: > Do you maybe > have several copies of the script lying around in different folders? I _think_ that you may have the answer here - tho' for me it raises almost as many questions as I had in the first place. The exercise I was having that intractable problem with was ex25. ex26 involves downloading a file from the Internet and finding and correcting the errors. In error, I downloaded ex26 before I had done ex25. So I left it and did ex25. Having finally given up on ex25, I am now doing ex26. And guess what?! Line 10 has a missing colon. So _how_ did a missing colon in ex26 cause problems in ex25 Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] broken script - curiouser and curiouser
On Thursday 07 July 2011 11:46:01 Marc Tompkins wrote: > On Thu, Jul 7, 2011 at 3:15 AM, Lisi wrote: > > There must have been > > something, but I cannot fathom what. What difference does inserting a > space > > > and then deleting it make? > > I wonder whether you might have had a stray non-printing character in > there? I believe that that would explain the symptom; of course, I have no > idea how it would have got there, so this merely pushes the mystery down a > layer! Low be it whispered I thought of that and copy-pasted into a WP and turned on non-printed characters. There were none. Only those that were there advisedly. One day when I am even older and even greyer I may look at this and a light may dawn and say: "So *that's* what was happening." Thanks for the input! Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] broken script - curiouser and curiouser
On Thursday 07 July 2011 10:21:59 Walter Prins wrote: > Hi Lisi > > On 7 July 2011 08:52, Lisi wrote: > > > > You could obviously see something wrong > > > > > > The posted error report had no colon. > > > > Yes - but the script had one, which was why I included the actual script > > in my > > original post. I seem to have cut too much in this email! > > The error message from Python is quoting what the interpreter read/saw from > the script file it was running. If it quoted no colon, then there was no > colon in the python file read by the interpreter, at the time that it tried > to run it. Your job is to figure out how this has happened. Do you maybe > have several copies of the script lying around in different folders? No. KWrite keeps an automatic backup, but I never use it. As a result of your question, I have just run the automatic backup. It runs fine. > Were > you maybe editing the the file (and keeping it open in the editor) while > running it from a command prompt every so often and did you maybe not save > the change before running the script I did do that once or twice during the long saga, but immediately realised and saved the file before running again. In fact, I think that it must sometimes have been saved multiple times because I was so afraid that I would do that. > (so that there may have been a > discrepancy between the script on disk that was run by the interpreter and > the script in your editor window)? I can see nothing that could have caused it. :-( Believe me, I thought of all the possibilities that have been mentioned so far and tried them out, with no joy. The only thing that worked was inserting a space and then, at Alan's suggestion, removing it. I am completely baffled. There must have been something, but I cannot fathom what. What difference does inserting a space and then deleting it make? At least this confirms that I took all the right debugging steps. I think I just have to write it down as one of life's little mysteries. If I can't uncover what happened with the files in front of me, clearly people who can see neither the screen nor the files have an impossible task! I am very grateful for all the list's help. I may have been left with the puzzle, but I have learnt a lot in the process of trying to debug the script. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] broken script - curiouser and curiouser
On Thursday 07 July 2011 00:48:24 Alan Gauld wrote: > "Lisi" wrote > > >> : File "ex26.py", line 10 > >> : def print_first_word(words) > >> : ^ > >> : SyntaxError: invalid syntax > >> : lisi@Tux:~/Python/LearnPythonTheHardWay$ > >> > >> Look at the error. Look at the error carefully. > > > > I could see nothing that was different. > > The error report says you had no colon in your code. > Python couldn't see it... But there *was* a colon. So why couldn't python see it? > Are you sutre you didn't add it before posting but > after running the code? Positive. > Or are you testing it by impotrting a module? > In that case the interpreter may still be using > the old version because you haven't reloaded > the updated version? No > > Yes - it was one of the first things I looked for when > > the error came up (that and check that the brackets > > were right). It was there in what seemed to me > > to be the right position. > > In that case I suspect the module theory. > How are you running the code? $ python ex14.py > > In the end, having tried absolutely everything else > > I could think of, and given that the error arose at > > the closing bracket at the end of line 10, I > > tried the only thing I could remotely think of that > > I hadn't tried and put a space in between the > > second bracket and the colon - and the wretched thing > > ran. > > As you know that shouldn't have made any difference. > Did you try going back and removing the space again > and see if the error came back? I now have at your suggestion, and it runs. So I am now still more mystified. As I say I had tried retyping it (and checking carefully) umpteen times and also copied and pasted from a succesful function definition and checked the brackets and colon every time. > > You could obviously see something wrong > > The posted error report had no colon. Yes - but the script had one, which was why I included the actual script in my original post. I seem to have cut too much in this email! Thanks, Alan. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] broken script - curiouser and curiouser
Thanks very much Martin. I did "solve" the problem after you kindly emailed - but the solution has puzzled me more that the original problem. On Tuesday 05 July 2011 23:23:41 Martin wrote: > : lisi@Tux:~/Python/LearnPythonTheHardWay$ python ex26.py > : File "ex26.py", line 10 > : def print_first_word(words) > : ^ > : SyntaxError: invalid syntax > : lisi@Tux:~/Python/LearnPythonTheHardWay$ > > Look at the error. Look at the error carefully. > > Look at the definitions of your other functions > > Compare. What is different? I could see nothing that was different. > do you see the colon? Yes - it was one of the first things I looked for when the error came up (that and check that the brackets were right). It was there in what seemed to me to be the right position. > > def silly_function(args): > > Curiously, the sample that you pasted above has the required colon > at the end of the line which starts the function definition. > > : def print_first_word(words): > : """Prints the first word after popping it off.""" > : word=words.pop(0) > : print word > > I have heard people express frustration many times about how a > program(ming language) or "the computer" did not understand > something because the thing was 'missing a damned semicolon'. I know that the smallest difference matters when dealing with a computer but could - and can - find none. > Try again, keep with it, and recognize that these beasties are > awfully particular in what they accept. And, for good reason. I have no difficulty with the fact that computers are literal minded. They are after all, machines. But "try again" was obviously great advice, and you had given me the push I needed to try again when I had given up. In the end, having tried absolutely everything else I could think of, and given that the error arose at the closing bracket at the end of line 10, I tried the only thing I could remotely think of that I hadn't tried and put a space in between the second bracket and the colon - and the wretched thing ran. So I altered line six in the same way - and that still ran. So line six will run either with or without the space. I then typed the next 2 sections in, and they ran, like line 6, either with or without the space. So line 10 needs a space and the other sections are happy either with or without. And they all have """ at the beginning of the next line. You could obviously see something wrong that I had continued, and continue, to miss, and I have still not found it. Hitting on the "right" solution almost by serendipity doesn't really count as seeing something wrong!! > Best of luck, Lisi, Thanks again very much Martin. You really encouraged me. I am obviously not going to get any further now, I am so bogged down in the whole thing. So I think that I may need to pass on and come back to it later. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] broken script
I am copy-typing the following pre-written program: def break_words(stuff): """This function will break up words for us.""" words=stuff.split(' ') return words def sort_words(words): """Sorts the words.""" return sorted(words) def print_first_word(words): """Prints the first word after popping it off.""" word=words.pop(0) print word I am testing at the end of each section as I type it. As far as line 9 it was fine - but, once I have typed up to line 14, it jibs at line 10 with the following error message: lisi@Tux:~/Python/LearnPythonTheHardWay$ python ex26.py File "ex26.py", line 10 def print_first_word(words) ^ SyntaxError: invalid syntax lisi@Tux:~/Python/LearnPythonTheHardWay$ (The caret should be under the closing bracket at the end of the line in which it is the penultimate character.) I have deleted and re-copy-typed the end of the line repeatedly. In despair, I deleted the end of the line and copied and pasted the end of line 6 into it. I have checked and rechecked for incorrect white-space. I can find nothing wrong. I have copy-pasted it into a WP just to make the non-printing characters visible. I can still see nothing wrong. Why is line 6 fine and line 10 a disaster? I can see no difference in the syntax, though there must clearly be one. :-( I am at a loss as to what to do next. (It is the next exercise that is supposed to have errors in for us to put right!!!) Pointers in the right direction very gratefully received! Thanks, Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with making emacs work with python syntax checking?
On Monday 04 July 2011 15:46:31 Tidal Espeon wrote: > I need help with installing this setup on my emacs: > http://hide1713.wordpress.com/2009/01/30/setup-perfect-python-environment-i >n-emacs/ The problem is that I have no clue how to access any .emacs file or > .emacs.d folder. I'm running linux, and they are apparently invisible in my > home directory. Trying to create those makes linux tell me that they're > already there. I've already installed the latest ropemacs, pyflakes, etc. > I'd sincerely appreciate help, since the IDLE just doesn't cut it for me. Do you know how to access hidden files, or is that the problem? In fact, do you know what hidden files are? If you can give me some indication of your skill level (see above questions) and your distro (including version) and DE, I might be able to help you; or anyhow point you in the right direction. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Thank you. Was: Re: problem reading script
Thank you all for such a lot of very helpful replies. I have been looking through the recommended fonts and am pleasantly surprised by how clear, legible and well differentiated some of them are. I have been using Bitstream Vera Sans Mono in KWrite, which gives me all the colours and spacing and is very easy to read, but Bitstream Vera Sans Mono, like Bitstream Vera Sans itself, does not distinguish well between I and l, nor between '' and " (which are in fact different, but the difference is noticeable only if you juxtapose them). I have already installed Inconsolata because there turned out to be a Debian package for it, so it took less than a minute to search for it - yes, it was there - and install it. And I have set KWrite to use it. Sadly, I am tied up all day tomorrow (it is late on Friday here) so I'll look into the other fonts on Sunday and work through the rest of your advice. I might even end up being able to code in Python - but if I do it will be because you have all hauled me over the fences. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] 2to3 conversion
On Friday 01 July 2011 14:05:22 Steven D'Aprano wrote: > Oh my, that's hilarious. > > Sorry folks, nothing to see here... I accidentally clicked on an unread > email from 2010 (!!!) and thought it had just come in. I'm glad that my eyes hadn't mislead me that much!! I was trying to find the original. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] problem reading script
On Friday 01 July 2011 14:26:07 Steven D'Aprano wrote: > If they look the same to you, then you need to increase your font size, > change to a programmers font, or possible clean your glasses :) Thanks for the reply, Steven. Suggestions for "a programmers font" gratefully received. I do have problems with my sight, and need to have my browser set to a font that I can read. But I could copy and paste to a WP and change the font for just that little bit. This particular text seems to work with a serif font. But it would be useful to know a specific programmer's font for when I am having difficulty seeing this particular distinction. I am used to having to look at just one word in a different font to distinguish between I and l (which currently look identical to me), where the context doesn't help. All I have to do now is work out/ look up what '' means!! Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] problem reading script
On Friday 01 July 2011 10:15:08 Lisi wrote: > I am supposed to be looking at scripts on-line, reading them and making > sure that I understand them. I think taht most of teh things I can't make > more than a guess at, are modules taht I don't know, and I can mostly make > them out. But the unpaired double quotation mark, " , in the following has > me stumped: > > report['BzrLogTail'] = ''.join(bzr_log_tail) > > The line ends accurately as it did in the script I was looking at. In case > you need the whole script to make out what the " means, the URL is: > http://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev/view/head:/apport/source_b >zr.py So sorry. Forgot to check typos before clicking on . :-( ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] problem reading script
I am supposed to be looking at scripts on-line, reading them and making sure that I understand them. I think taht most of teh things I can't make more than a guess at, are modules taht I don't know, and I can mostly make them out. But the unpaired double quotation mark, " , in the following has me stumped: report['BzrLogTail'] = ''.join(bzr_log_tail) The line ends accurately as it did in the script I was looking at. In case you need the whole script to make out what the " means, the URL is: http://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev/view/head:/apport/source_bzr.py and I have copied and pasted the function definition in which it is to be found after my signature. I would be extremely grateful for an explanation/translation! Lisi def _add_log_tail(report): # may have already been added in-process if 'BzrLogTail' in report: return bzr_log_lines = open(bzr_log).readlines() bzr_log_lines.reverse() bzr_log_tail = [] blanks = 0 for line in bzr_log_lines: if line == '\n': blanks += 1 bzr_log_tail.append(line) 27 if blanks >= 2: 28 break 29 30 bzr_log_tail.reverse() 31 report['BzrLogTail'] = ''.join(bzr_log_tail) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Defining a "format string"
On Sunday 26 June 2011 17:15:14 Alan Gauld wrote: > "Lisi" wrote > Umm, nearly... > The format string contains format specifiers. They are not variables. > The specifiers define the type of data to be inserted into the string > as well as how the data will be formatted - hence the name. > > So you can specify how many decimal places for a float, whether > numbers have leadig zeros, whether text is righ or left justified and > more. > HTH, Definitely. I am very grateful. I have been unclear about this for some time and _think_that I have at last got it. The things I asked questions about were the things I either knew or thought that I had got wrong. I kept hoping that context would make things clear in the end, as indeed it often does. But on this subject it clearly didn't. So thanks for all the help. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Defining a "format string"
Thanks, Noah and Steven. :-) On Sunday 26 June 2011 12:24:12 Steven D'Aprano wrote: > Lisi wrote: > > In the following excerpt from a program in the book I am following: > > > >print "If I add %d, %d, and %d I get %d." % ( > > my_age, my_height, my_weight, my_age + my_height + my_weight) > > > > is > > > > % ( > > my_age, my_height, my_weight, my_age + my_height + my_weight) > > > > the/a format string? > > No. The format string is a string with the % codes. In this case, they > are all %d codes: > > "If I add %d, %d, and %d I get %d." > > but there are other codes possible. > > The % symbol on its own is an operator, like + or * or / > > The part inside the brackets () is a tuple of values to insert into the > format string. Putting the three together: > > > target = "Hello %s." > value = "Lisi" > print target % value > > => prints "Hello Lisi." At least I had managed to pick up correctly that the format string needed a % symbol! So, if I have now understood correctly, a format string is a string containing at least one variable, and the variable(s) is/are preceded by the % symbol. Yes??? Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Defining a "format string"
In the following excerpt from a program in the book I am following: print "If I add %d, %d, and %d I get %d." % ( my_age, my_height, my_weight, my_age + my_height + my_weight) is % ( my_age, my_height, my_weight, my_age + my_height + my_weight) the/a format string? If not, then I still haven't "got" it, and I would be very grateful if someone could define "format string" for me - preferably in words of one syllable, because I seem to be being a bit thick about this. :-( Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] line continuation characters
On Monday 20 June 2011 00:03:47 Steven D'Aprano wrote: > Lisi wrote: > > I am having problems with line continuation characters. Error message: > > > > SyntaxError: unexpected character after line continuation character > > Then delete it ;) > > Seriously. You have your editor open, right? Go to the line where the > error is reported. It will look something like this: > > blah blah blah \ > > Press the End key. Your editor's blinking insertion point or cursor will > go to the end of the line: > > blah blah blah \ | > > Backspace until the cursor is *immediately* next to the backslash, with > no other characters INCLUDING SPACES after it. > > Which editor are you using? If it is kwrite or kate, it has a setting to > control whether spaces are left at the end of lines, e.g. in kwrite: > > Settings > Configure Editor > Editing > Remove trailing spaces > > > I have succeeded in moving the position of the complaint, but am > > currently well and truly stuck. > > > > I have read up about it and now (I hope!) know what to do about it in > > general, but at one particular point everywhere seems to be wrong. Is > > there any way I can make these wretched continuation characters visible, > > so that I know where and what I am up against? > > Continuation characters are visible. It is a backslash at the very end > of the line. It must not be followed by *anything* -- no comments, no > spaces, nothing. > > >>> x = 23 + \ > >File "", line 1 > x = 23 + \ >^ > SyntaxError: unexpected character after line continuation character > > > If this error message is not clear, would you like to suggest an > improvement? It is not the error message that is unclear, it was the state of my knowledge. I did not know that \ was a line continuation character, and simply wrote a long line which wrapped. I know how to remove spaces - I just had not got a clue what the message was on about. I found quite a few references to line continuation characters, but nothing that told me what a line continuation character looked like, nor that it must be at the very end of the line. The back-slashes in the script all had other purposes, and I had not realised that where they fell was significant. Thanks for the help. Now to tackle my script. Lisi Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] line continuation characters
I am having problems with line continuation characters. Error message: SyntaxError: unexpected character after line continuation character I have succeeded in moving the position of the complaint, but am currently well and truly stuck. I have read up about it and now (I hope!) know what to do about it in general, but at one particular point everywhere seems to be wrong. Is there any way I can make these wretched continuation characters visible, so that I know where and what I am up against? Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] nitinchandra rubbish on list
On Sunday 19 June 2011 15:10:51 Válas Péter wrote: > Each time I send a message to this list, I get an autoreply like this. No, > I won't add myself to any stupid guestlists to use a public list. Could a > list moderator please show this user the exit? The solution is simple. Never reply to emails from this particular person. (I can quite understand your not wanting to add yourself to any list.) Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Closing triple quotation marks.
On Sunday 19 June 2011 14:23:25 col speed wrote: > On 19 June 2011 14:46, Lisi wrote: > > On Sunday 19 June 2011 08:39:43 Alan Gauld wrote: > > > "Lisi" wrote > > > > > > > It does indeed. Thank you, both of you. I have clearly not got the > > > > terms > > > > command, method, function (and feature?) clearly sorted out in my > > > > mind, so > > > > that is obviously where I need to go. I am supposed to be > > > > researching > > > > import, but I have not yet succeeded in seeing why it is a problem. > > > > So I'll > > > > switch to looking up method, function etc. > > > > > > Add "callable" to your list of search terms. > > > Python has the concept of "callable objects" and > > > you can call a callable by using parentheses. > > > You can also test whether an object is callable > > > or not: > > > > > > for obj in list_of_objects: > > > if callable(obj): > > > print obj() # call obj first > > > else: > > > print obj# just use the obj value > > > > > > HTH, > > > > Thank you! > > > > Lisi > > > > ___ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > http://mail.python.org/mailman/listinfo/tutor > > A good way to learn is making mistakes(in language it's the *only* way). I > don't think I will mistake variable_name with "variable_name" in the near > future! > I downloaded a text file of prime numbers - lots of them. Being clever(!), > I knew they were strs and I had to convert them to ints, so: > 1. I put them all in memory - first mistake, but not fatal > 2. I, very cleverly(I thought) used a list comprehension to convert them to > ints - OK > 3. I did something like: > for prime in tooManyPrimes: > f.write("prime") > > I did this with about 6 files! !! ;-) Thank you for the marvellous mental image! Prime numbers will never be the same again. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Closing triple quotation marks.
On Sunday 19 June 2011 08:39:43 Alan Gauld wrote: > "Lisi" wrote > > > It does indeed. Thank you, both of you. I have clearly not got the > > terms > > command, method, function (and feature?) clearly sorted out in my > > mind, so > > that is obviously where I need to go. I am supposed to be > > researching > > import, but I have not yet succeeded in seeing why it is a problem. > > So I'll > > switch to looking up method, function etc. > > Add "callable" to your list of search terms. > Python has the concept of "callable objects" and > you can call a callable by using parentheses. > You can also test whether an object is callable > or not: > > for obj in list_of_objects: > if callable(obj): > print obj() # call obj first > else: > print obj# just use the obj value > > HTH, Thank you! Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Closing triple quotation marks.
On Saturday 18 June 2011 15:58:23 Alan Gauld wrote: > "Lisi" wrote > > > But I still can't write to the file. > > > > If I do: > > target.write(line1) > > > > The value of the variable line1 is written to the file. > > That will work provided line1 is a string. > > > But if I put the three variables into the write command, > > what gets printed is the name of the variables, not their values. > > > > At the moment it is: > > target.write(""" > > line1 > > line2 > > line3 > > """) > > This is not three variables it is a single string value that > coincidentally has the names of three of your variables > inside it. But Python has no way to guess that. > > You need to be clear on the different between a variable: > a name that references a value(or object if you prefer) > and a string which is a type of value(a string object) > > In the first case you pass a name (line1) in the second > you pass a value (the string literal) > > > I am beginning to feel paranoid! I simply can't see in what way > > that differs > > from yours. > > quote signs > > > I have, I hope, finally _fully_ taken in that many commands need (). > > Actually commands do not usually need (), it is functions and methods > that need (). They are different. > > print is a command and it does not need () - in Python 2 at least! > > print 1,2,"some words" > > But file.write() is a method of the file object and must have > parentheses. > > f.write("some words") > > The () are an instruction to execute the function. Without > the () Python treats the function as an object in its own right: > > list_of_objects = [1,"a string",f.write] > > for obj in list_of_objects: > print "Object is: ", obj > > > it is possible to get a new line just by giving a new line - without > > the > > explicit instruction. > > That is the unique selling point of triple quoted strings, > you can embed newlines inside them. This makes them > most useful for docstrings (which decribe what a function > is for): > > def myFunc(): > """"myFunc() -> None > > Does some useful background processing with no obvious impact on > data. > """ > theAnswer = 7*6 > > > HTH, It does indeed. Thank you, both of you. I have clearly not got the terms command, method, function (and feature?) clearly sorted out in my mind, so that is obviously where I need to go. I am supposed to be researching import, but I have not yet succeeded in seeing why it is a problem. So I'll switch to looking up method, function etc. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Closing triple quotation marks.
On Saturday 18 June 2011 13:37:38 Steven D'Aprano wrote: > Lisi wrote: > [...] > > > Fair enough. the closing quotation marks are not there. > > > > But when they _are_ there, i.e. when that stanza reads: > > > > target.write """ > > line1\nline2\nline3\n > > """ > > This is not the problem, but I just thought I'd mention that it's a bit > silly to go to the trouble of using newline escape characters inside a > triple-quoted string! You can do it if you want, but this would be more > naturally written as: > > """ > line 1 > line 2 > line 3 > """ > > Now, on to your actual error: > > I get: > > > > lisi@Tux:~/Python/LearnPythonTheHardWay$ python extra-credit_16a.py > > learning.txt > > File "extra-credit_16a.py", line 38 > > """ > > ^ > > SyntaxError: invalid syntax > > This has nothing to do with the triple quote marks. Simplify the code by > shrinking the text inside the quotes to a single line, and you get: > > target.write "..." > > > and you will get the same SyntaxError. Can you see the problem? No > brackets! You need to include parentheses to call the write method: > > target.write("...") > > > Then you can expand the string to use a triple-quote: > > target.write(""" > line 1 > line 2 > line 3 > """) > > and all should be good. Thanks very much, Steven. I did at some stage in the dim and distant past try brackets, but I probably put them in the wrong place. But I still can't write to the file. If I do: target.write(line1) The value of the variable line1 is written to the file. But if I put the three variables into the write command, what gets printed is the name of the variables, not their values. I am clearly still doing something wrong. But I can't see what. I have even tried to see whether ''' gave a different result from """, but it doesn't. I have accepted KWrite's idea of what the white space should be, and I have adapted it to all the variations I can think of. At the moment it is: target.write(""" line1 line2 line3 """) I am beginning to feel paranoid! I simply can't see in what way that differs from yours. In case it is relevant, I am using Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) [GCC 4.3.2] on Debian 5 with a 2.6.26 kernel. I was trying not to move on until I had mastered everything in this section, but I am beginning to think that that is foolish. I am getting myself more and more bogged down, and it might be more sensible to pass on and come back to it. Again, thank you for your very prompt help. I have, I hope, finally _fully_ taken in that many commands need (). And that it is possible to get a new line just by giving a new line - without the explicit instruction. I.e., hopefully, I have learnt something. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Closing triple quotation marks.
I have left the program intact below* because I am afraid that if I cut it I may cut out something that is essential. I am working from an existing program that I have typed out under instructions, but am now trying to replace the commented out section with just one command. The program with the commented out section worked fine. I have been stuck for some hourslast night andagain this morning. I have inserted the print command after the commented out section in order simply to try out whether the triple quotation marks ever work as I thought they did, and the answer is yes they do. If I leave the target.write without the final """, I get the error (which I would indeed expect): lisi@Tux:~/Python/LearnPythonTheHardWay$ python extra-credit_16a.py learning.txt File "extra-credit_16a.py", line 42 ^ SyntaxError: EOF while scanning triple-quoted string lisi@Tux:~/Python/LearnPythonTheHardWay Fair enough. the closing quotation marks are not there. But when they _are_ there, i.e. when that stanza reads: target.write """ line1\nline2\nline3\n """ I get: lisi@Tux:~/Python/LearnPythonTheHardWay$ python extra-credit_16a.py learning.txt File "extra-credit_16a.py", line 38 """ ^ SyntaxError: invalid syntax So where should I be putting those wretched triple quotes? I have been stuck on this for hours. With the target.write stanza there, none of the rest of the program works either. If I comment out the target.write stanza and leave the print stanza above it alone, the whole program runs as I would expect it to. I have searched the Python.org site; I have googled; I am stuck and have run out of ideas. Lisi *Herewith the program: from sys import argv script, filename=argv print "We're going to erase %r." % filename print "If you don't want that, hit CTRL-C (^C)." print "If you do want that, hit RETURN." raw_input("?") print "Opening the file..." target=open(filename, 'w') print "Truncating the file. Goodbye!" target.truncate() print "Now I'm going to ask you for three lines." line1=raw_input("line1: ") line2=raw_input("line2: ") line3=raw_input("line3: ") print "I'm going to write these to the file." # target.write(line1) # target.write("\n") # target.write(line2) # target.write("\n") # target.write(line3) # target.write("\n") print """ line1\nline2\nline3\n """ target.write """ line1\nline2\nline3\n print "And finally we close it." target.close() ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Reading opened files
On Friday 17 June 2011 17:42:29 Walter Prins wrote: > On 17 June 2011 17:20, Lisi wrote: > > >>> file=open("/home/lisi/CHOOSING_SHOES.txt", "r") > > >>> file.close() > > >>> file=open("/home/lisi/CHOOSING_SHOES.txt", "r") > > >>> whole=file.read > > >>> print whole > > > > > > > > >>> print "%r" % whole > > > > > > > > >>> print "whole is %r" %whole > > > > whole is > > > > >>> print "whole is %r" % whole > > > > whole is > > You're missing the () off the whole=file.read() call. > > Ask youself, what is "file.read"? It is of course a method of the "file" > object. And, in fact that's exactly what Python itself is telling you > also. So when you say: > > whole=file.read > > You're assigning the method itself, to the name "whole". Consequently, you > would be able to do: > > something = whole() > > ... which would then *call* the function using the name "whole", which > would be identical to calling that same function via "file.read". > > To reiterate, there's a difference between just referencing a method or > function and actually calling it. To call it you need to use parentheses. Thanks, Walter. That is also very useful and clear. As with James's answer, I have left this intact for the archives. It should be available for other newbies who are blundering about a bit. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Reading opened files (SOLVED)
So sorry to have troubled you all. The light suddenly dawned. Perhaps because I was more relaxed, having asked the list? Anyhow, I now know how to do it, and it is of course, simple. [Passing on and coming back would obviously have worked, but the author had said not to do that this time. :-( ] Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Reading opened files
Hello :-) I have got as far as I have,i.e. apparently succeeding in both opening and closing two different files, thanks to google, but my struggles to _do_ something with a file that I have opened are getting me nowhere. Here is my latest failure: >>> file=open("/home/lisi/CHOOSING_SHOES.txt", "r") >>> file.close() >>> file=open("/home/lisi/CHOOSING_SHOES.txt", "r") >>> whole=file.read >>> print whole >>> print "%r" % whole >>> print "whole is %r" %whole whole is >>> print "whole is %r" % whole whole is >>> I'd be extremely grateful if one of you was willing to drop a hint, give me some pointers (even e.g. guide me to asking the correct question of Google), or tell me where I am going wrong. In general, the author advises leaving any of the extra credit questions that you are struggling with and coming back to them later. And in general I have found that that works. But this set of extra-credit questions he advises mastering before moving on. And I am stuck on this one at this stage. :-( (I think that I have cracked the others.) Thanks. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Beginner puzzle with unpacking argv
On Thursday 16 June 2011 19:03:27 Joel Goldstick wrote: > On Thu, Jun 16, 2011 at 1:10 PM, Lisi wrote: > > Copied and pasted: > > >From text of Learn Python the Hard Way > > > > 1 from sys import argv > > 2 > > 3 script, user_name = argv > > > > >From my script (typed, not copied and pasted, but copied and pasted from > > > > my > > script to here): > > > > 1 from sys import argv > > 2 > > 3 script, user_name = argv > > > > I have tried every permutation of white space I could think of that might > > have > > looked like the original, but I always get the same error: > > > > lisi@Tux:~/Python/LearnPythonTheHardWay$ python ex14.py > > Traceback (most recent call last): > > File "ex14.py", line 3, in > >script, user_name=argv > > ValueError: need more than 1 value to unpack > > > > I haven't got past line 3 yet!! I know that you need the right number of > > variables, but my script has got as many as the original - it's the same > > as the original! > when you run the program you are not giving it any arguments to read. > argv[0] is the name of your script. But you are not providing a value for > user_name to consume > > Try this: > > lisi@Tux:~/Python/LearnPythonTheHardWay$ python ex14.py Lisi Thanks to all of you, guys. :-)) So it wasn't the script that was wrong, it was the command I was giving. Doh! It now runs fine as far as I have gone, so I can now finish typing the rest of the script in. Hopefully without too many stupid mistakes. :-( Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] File parsing
Thanks, Neha. I am sending this back on list so that those who are more knowledgeable than I am can help you. On Thursday 16 June 2011 18:47:39 Neha P wrote: > Hi Lisi, > Below is the code and I have prefixed(-->) to the line code which i'm > mainly concerned about and have commented using # > > > > for eachline in f_obj: > > # to eliminate the trailing "\n" > -->eachline=eachline[ : -1] > list_words=eachline.split(" ") > # to add "\n" so that after line 1 is printed, line 2 should start on a new > line""" -->list_words[0]=list_words[0]+"\n" > list_words.reverse() > # 'comma' helps in printing words on same > # line, hence for last word have to append "\n" as done in above stmt > for every_word in list_words: > print every_word, > > > Thanks, > Neha > > > > > > From: Lisi > To: Neha P > Sent: Thursday, June 16, 2011 1:19 PM > Subject: Re: [Tutor] File parsing > > On Thursday 16 June 2011 18:03:55 Neha P wrote: > > Hi all, > > I know below query may sound silly, but can somebody suggest any better > > way of doing this: > > > > It would be helpful. > > > > I need to read a file line by line and print each line starting from the > > last word first: > > C:\Python26>type file_reversing_program.txt > > > > import sys > > import string > > > > f_obj=open(sys.argv[1],"r") > > > > for eachline in f_obj: > >eachline=eachline[ :-1]# to eliminate the trailing "\n" > > list_words=eachline.split(" ") > >list_words[0]=list_words[0]+"\n"# to add "\n" so that after line 1 is > > printed, line 2 should start on a new line list_words.reverse() > > for every_word in list_words: > > print every_word,# 'comma' helps in printing words on same > > line,hence for last word we append "\n" > > > > f_obj.close() > > > > C:\Python26>type input_file.txt > > > > "Hi ther, how are you?" > > I are doing fine, thank you. > > > > C:\Python26>file_reversing_program.py input_file.txt > > > > you?" are how ther,"Hi > > you. thank fine, doing are I > > > > Is there a better way of doing the above program, mainly the text > > highlighted in yellow, Also if that is settled can there be a logic for > > getting the ouput more properly formatted (for text in blue) , say giving > > an output like : > > "you? are how ther, Hi" > > you. thank fine, doing are I > > > > > > > > Thanks, > > Neha > > Colours haven't transmitted (I use plain text). > > Could you identify the blocks of text by some other means? > > Thanks, > Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Beginner puzzle with unpacking argv
Copied and pasted: >From text of Learn Python the Hard Way 1 from sys import argv 2 3 script, user_name = argv >From my script (typed, not copied and pasted, but copied and pasted from my script to here): 1 from sys import argv 2 3 script, user_name = argv I have tried every permutation of white space I could think of that might have looked like the original, but I always get the same error: lisi@Tux:~/Python/LearnPythonTheHardWay$ python ex14.py Traceback (most recent call last): File "ex14.py", line 3, in script, user_name=argv ValueError: need more than 1 value to unpack I haven't got past line 3 yet!! I know that you need the right number of variables, but my script has got as many as the original - it's the same as the original! Help! Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Floating point exercise 3 from Learn python the hard way
I too am working through Learn Python the Hard Way. On Tuesday 14 June 2011 14:20:43 amt wrote: > sadly the author of the > book doesn't provide the solutions to the exercises. He gives the answers to the questions in the main block of the chapter, just not for the extra credit questions. I have taken the attitude that if I can't do any of the extra credit questions, having successfully done the questions in the chapter, I pass on and will come back to them when I know a bit more. Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Interview Questions..
On Saturday 28 May 2011 05:25:45 Steven D'Aprano wrote: > >> Not sure what you're saying here Alan -- are you saying you consider > >> Java "hard enough language to seperate great programmers from plodders" > > > > Yes, I'm saying the language just isn't that significant. > > Sorry Alan, you confuse me. Do you mean Java isn't that *insignificant*? Surely he is saying that it doesn't make much difference to this which language you are using? Lisi ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor