Re: [Tutor] Pygame

2009-07-23 Thread Albert Sweigart
Hi, I'm Al, the author of Invent Your Own Computer Games with Python. The book does indeed cover Pygame. The last four chapters covers the Pygame library, and the final one has the source code for a complete game. I still recommend learning Python first though, it will make it much easier to under

Re: [Tutor] R?p. : Sorting Data in Databases

2009-11-23 Thread Albert Sweigart
Ken, You should probably use the sorting functionality that your DBMS provides. However, if you have a list of strings that end with a new line and start with an apostrophe, you can use list comprehensions to remove them: newlist = [x[1:-1] for x in newlist] You can look at the following links t

Re: [Tutor] Difficulty with csv files - line breaks

2009-11-24 Thread Albert Sweigart
Tim, I've checked your code and it seems to work as far as using newlines for the line terminator. The default line terminator is \r\n, which might not show up correctly in some text editors. Otherwise, try checking to see if you've specified a blank line for the line terminator. You can set it e

Re: [Tutor] When max() doesn't work as expected

2009-12-03 Thread Albert Sweigart
max() for strings returns the largest string in an alphabetical sense. So max(['z', 'aa']) would return 'z'. You need to specify an ordering function, in your case, len(): max( ['z', ''], key=len) ...which will return '' because it is ordering by key. -Al Sweigart

Re: [Tutor] What books do you recommend?

2009-12-09 Thread Albert Sweigart
I'd recommend Doug Hellman's Python Module of the Week blog (PyMOTW) at http://www.doughellmann.com/projects/PyMOTW/ He goes into each of the standard library modules and gives examples of them in use. Dive Into Python 3 by Mark Pilgrim is also good for getting up to speed on Python 3. http://div

Re: [Tutor] Append mode dilemma

2009-12-09 Thread Albert Sweigart
Your problem is on this line: fobj.write('\n'.join(all)) This puts a newline in between each line in "all", but not at the end. The fix is simple: fobj.write('\n'.join(all) + '\n') This will make sure that the last line has a newline at the end of it, so that when you later append data, it will

Re: [Tutor] Learn Python

2009-12-12 Thread Albert Sweigart
I'd recommend my book, "Invent Your Own Computer Games with Python", which is available for free at: http://inventwithpython.com Each chapter focuses on the complete source code for a small game, and teaches programming concepts from the code. -Al > Hi > I'm trying to learn python but I have di