Re: [Tutor] An interesting situation befalls me
It is interesting to note war against 'Dive into Python'. Personally I felt it was good, a quick resource to learn without buying O'reilly books. After I came across Alan Gauld and Mark Lutz's books, I never referred DintoP. I still have the printed version of this book from 2002-3 I guess. After a variety of circus maneuvers, I came to the following conclusion: 1. Go to http://www.freenetpages.co.uk/hp/alan.gauld/ Alan Gauld's book is a wonder. He feeds the basics right into your brain. 2. With Alan's book as basic I bought Mark Lutz's Learning Python. 3. Make use of tutors list. I owe a lot to people here like Alan and Kent Johnson. In no time, you can be a good programmer. this is my personal opinion and nothing to do with Zed's war on DintoP. From: Steven D'Aprano To: tutor@python.org Sent: Sat, May 8, 2010 11:43:50 PM Subject: Re: [Tutor] An interesting situation befalls me On Sun, 9 May 2010 07:31:15 am Kirk Z Bailey wrote: > An instructor of mine is about to teach the FIRST EVER class in > Python at Saint Petersburg College; knowing I am a snakecharmer, he > asked me for referrals to online resources. > > Oh my. > > So I sent back this: [...] > And you can swim into it at diveintopython: >http://diveintopython.org/toc/index.html Here's a counter-opinion: Dive Into Python must die! http://oppugn.us/posts/1272050135.html And a few more suggestions: http://inventwithpython.com Learn Python the Hard Way: http://learnpythonthehardway.com/index -- Steven D'Aprano ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] An interesting situation befalls me
On Sun, 9 May 2010 13:43:50 +1000 Steven D'Aprano wrote: > Here's a counter-opinion: > > Dive Into Python must die! > http://oppugn.us/posts/1272050135.html I 100% share the article author's opinion. This "book" was surely crafted with the only intention to disgust anybody of programming. A shame (the word is too weak, but english is a foreign language for me so I need to be prudent ;-), have a look at the book yourself and tell me what proper qualifier matches that horror); even more since it uses python and pretends to introduce to this language. I guess the only thing to do is to spread the word "do NOT even have a look at 'dive into python'" to everybody wishing to learn about programming and/or python. Sorry for such bad words, but I think some things cannot be left unsaid. Denis vit esse estrany ☣ spir.wikidot.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] reading binary file on windows and linux
On Sun, 9 May 2010 19:33:51 +0200 Jan Jansen wrote: > Hello, > > I've got some trouble reading binary files with struct.unpack on windows. > According to the documentation of the binary file's content, at the > beginning there're some simple bytes (labeled as 'UChar: 8-bit unsigned > byte'). Within those bytes there's a sequence to check the file's sanity. > The sequence is (in ascii C-Notation): > " " > "\n" > "\r" > "\n" > " " > I've downloaded the file from the same website from two machines. One is a > Windows 7 64-Bit, the other one is a virtual Linux machine. Now the trouble > is while on linux everything is fine, on windows the carriage return does > not appear when reading the file with struct.unpack. > > The file sizes on Linux and Windows are exaktly the same, and also my script > determines the file sizes correctly on both plattforms (according to the > OS). When I open the file on Windows in an editor and display the > whitespaces, the linefeed and cariage-return are shown a expected. > > The code I'm using to check the first 80 bytes of the file is: > > import struct > import sys > > with open(sys.argv[1]) as source: > size = struct.calcsize("80B") > raw_data = struct.unpack("80B", source.read(size)) > for i, data in enumerate(raw_data): > print i, data, chr(data) > source.seek(0, 2) > print source.tell() I guess (but am not 100% sure because never use 'b'), the issue will be solved using: with open(sys.argv[1], 'rb') as source: The reason is by default files are opened in read 'r' and text mode. In text mode, whatever char seq is used by a given OS with the sense of "line separator" ("\r\n' under win) is silently converted by python to a canonical code made of the single '\n' (char #0xa). So that, in your case, in the header sub-sequence '\r'+'\n' you lose '\r'. In so-called bynary mode 'b' instead, python does not perform this replacement anymore, so that you get the raw byte sequence. Hope I'm right on this and it helps. Denis vit esse estrany ☣ spir.wikidot.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] reading binary file on windows and linux
On Mon, 10 May 2010 03:33:51 am Jan Jansen wrote: > Hello, > > I've got some trouble reading binary files with struct.unpack on > windows. [...] > The code I'm using to check the first 80 bytes of the file is: > > import struct > import sys > > with open(sys.argv[1]) as source: You're opening the file in text mode. On Linux, there's no difference, but on Windows, it will do strange things to the end of lines. You need to open the file in binary mode: open(sys.argv[1], 'rb') -- Steven D'Aprano ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] reading binary file on windows and linux
On Sun, May 9, 2010 at 7:33 PM, Jan Jansen wrote: > Hello, > > I've got some trouble reading binary files with struct.unpack on windows. > According to the documentation of the binary file's content, at the > beginning there're some simple bytes (labeled as 'UChar: 8-bit unsigned > byte'). Within those bytes there's a sequence to check the file's sanity. > The sequence is (in ascii C-Notation): > " " > "\n" > "\r" > "\n" > " " > I've downloaded the file from the same website from two machines. One is a > Windows 7 64-Bit, the other one is a virtual Linux machine. Now the trouble > is while on linux everything is fine, on windows the carriage return does > not appear when reading the file with struct.unpack. > > The file sizes on Linux and Windows are exaktly the same, and also my script > determines the file sizes correctly on both plattforms (according to the > OS). When I open the file on Windows in an editor and display the > whitespaces, the linefeed and cariage-return are shown a expected. > > The code I'm using to check the first 80 bytes of the file is: > > import struct > import sys > > with open(sys.argv[1]) as source: > size = struct.calcsize("80B") > raw_data = struct.unpack("80B", source.read(size)) > for i, data in enumerate(raw_data): > print i, data, chr(data) > source.seek(0, 2) > print source.tell() > Since the file is binary, you should use the "b" mode when opening it: with open(sys.argv[1], "rb") as source: otherwise, the file will open in text mode, which converts newline characters to/from a platform specific representation when reading or writing. In windows, that representation is \r\n, meaning that that sequence is converted to just \n when you read from the file. That is why the carriage return disappears. Hugo ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] reading binary file on windows and linux
On 9 May 2010 18:33, Jan Jansen wrote: > Hello, > > I've got some trouble reading binary files with struct.unpack on windows. > According to the documentation of the binary file's content, at the > beginning there're some simple bytes (labeled as 'UChar: 8-bit unsigned > byte'). Within those bytes there's a sequence to check the file's sanity. > The sequence is (in ascii C-Notation): > " " > "\n" > "\r" > "\n" > " " > I've downloaded the file from the same website from two machines. One is a > Windows 7 64-Bit, the other one is a virtual Linux machine. Now the trouble > is while on linux everything is fine, on windows the carriage return does > not appear when reading the file with struct.unpack. > > The file sizes on Linux and Windows are exaktly the same, and also my > script determines the file sizes correctly on both plattforms (according to > the OS). When I open the file on Windows in an editor and display the > whitespaces, the linefeed and cariage-return are shown a expected. > > The code I'm using to check the first 80 bytes of the file is: > > import struct > import sys > > with open(sys.argv[1]) as source: > size = struct.calcsize("80B") > raw_data = struct.unpack("80B", source.read(size)) > for i, data in enumerate(raw_data): > print i, data, chr(data) > source.seek(0, 2) > print source.tell() > > > Any suggestions are highly appreciated. > > Cheers, > > Jan > I'd guess that it's because newline in windows is /r/n and in linux it's just /n. If you read the file as binary rather than text then it should work the same on both platforms ie use: open(sys.argv[1], "rb") HTH, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] reading binary file on windows and linux
Hello, I've got some trouble reading binary files with struct.unpack on windows. According to the documentation of the binary file's content, at the beginning there're some simple bytes (labeled as 'UChar: 8-bit unsigned byte'). Within those bytes there's a sequence to check the file's sanity. The sequence is (in ascii C-Notation): " " "\n" "\r" "\n" " " I've downloaded the file from the same website from two machines. One is a Windows 7 64-Bit, the other one is a virtual Linux machine. Now the trouble is while on linux everything is fine, on windows the carriage return does not appear when reading the file with struct.unpack. The file sizes on Linux and Windows are exaktly the same, and also my script determines the file sizes correctly on both plattforms (according to the OS). When I open the file on Windows in an editor and display the whitespaces, the linefeed and cariage-return are shown a expected. The code I'm using to check the first 80 bytes of the file is: import struct import sys with open(sys.argv[1]) as source: size = struct.calcsize("80B") raw_data = struct.unpack("80B", source.read(size)) for i, data in enumerate(raw_data): print i, data, chr(data) source.seek(0, 2) print source.tell() Any suggestions are highly appreciated. Cheers, Jan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] An interesting situation befalls me
On Sun, 9 May 2010 13:43:50 +1000 Steven D'Aprano wrote: > http://inventwithpython.com Yep, this one is great! (I gave it a nickname: "play programming!" Is this correct english?) Denis vit esse estrany ☣ spir.wikidot.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] An interesting situation befalls me revisited
Well, this has been a fruitful thread! Now here's the next exciting installment; what's a good TEXTBOOK for a class to use on the subject? -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] An interesting situation befalls me
As a new learner of programming I'd recommend Head First Programming "A learner's guide to programming, using the Python language" by O'Reilly. It is very basic. Joe On Sat, May 8, 2010 at 4:31 PM, Kirk Z Bailey wrote: > An instructor of mine is about to teach the FIRST EVER class in Python at > Saint Petersburg College; knowing I am a snakecharmer, he asked me for > referrals to online resources. > > Oh my. > > So I sent back this: > " > Ah, python., my fav obsession. First, the language website itself: > http://www.python.org/ > Natch, they offer a tutorial: > http://docs.python.org/tutorial/ > But this one is better for rank beginniners: > http://wiki.python.org/moin/BeginnersGuide/NonProgrammers > And there's another one here: > http://www.sthurlow.com/python/ > And a nice writeup on wikipedia: > http://en.wikipedia.org/wiki/Python_%28programming_language%29 > You may care to go teleport to planet python: > http://planet.python.org/ > And you can swim into it at diveintopython: > http://diveintopython.org/toc/index.html > " > > Now here is a chance to help influence this getting off on the right foot. > I can use reccomendations for texts for use in an introduction to Python > class, and I will condense it down and provide them to the good doctor. > > -- > end > > Very Truly yours, >- Kirk Bailey, > Largo Florida > > kniht+-+ > | BOX | +-+think > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] An interesting situation befalls me
"Alan Gauld" wrote Learn Python the Hard Way: http://learnpythonthehardway.com/index These were both new ones to me, thanks for sharing! I've just finished skimming this one and its pretty good IMHO! My only gripe is the final "chapter" - "Advice from an old programmer". It seems Mr Shaw has become somewhat disillusioned with the software engineering profession, but as someone who has beenn programming for at least as long as he has I have to say that I still enjoy it and find it rewarding both personally and financially. So don't let the final page of cynicism put you off a career in software engineering. Otherwise, if you are looking for a newbie tutorial this a is a good one although it has less depth than most other tutors, it's still a good first step. I assume it's still a work in progress too, since it jumps from Exercise (aka chapter) 10 to Excercise 27 in one go! HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] An interesting situation befalls me
"David Abbott" wrote Learning to Program by none other than Alan Gauld http://www.freenetpages.co.uk/hp/alan.gauld/ Thanks for the plug but the freenetpages site has been frozen for over 2 years. The current site (including the Python v3 version) is as in my .sig... -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] An interesting situation befalls me
"Steven D'Aprano" wrote And you can swim into it at diveintopython: http://diveintopython.org/toc/index.html Here's a counter-opinion: Dive Into Python must die! http://oppugn.us/posts/1272050135.html Hmmm, it sounds a bit like complaints from someone who has never written a book themselves! While some of the complaints are valid others simply reflect the time and place. I believe Mr Pilgrim has taken the conscious decision to have the web site mirror his book, so changing it would leave them out of synch. Similarly, I assume the book was a one-off project and he has no desire to revisit it. (Or maybe his publisher has no desire, it's not all in the author's control!) I took the alternative view that the book was a snapshot of my web site and the web site continues to evolve while the book is frozen in 1999. But both approaches are valid and Pilgrim's book still has much to teach, although it's definitely not for beginners and it's not one of my personal favourites. But if the style fits the reader I certainly wouldn't discourage its use. My own book took just short of 2 years to put together (and it already existed as a web site so I had the basic structure and words in place), updating a book is a significant commitment. Even updating my web site to Python v3 has taken me about 18 months so far and I'm only 70% through it... If you are not a full time author and it's not a primary revenue source it takes more than a change in technology to motivate a rewrite! And a few more suggestions: http://inventwithpython.com Learn Python the Hard Way: http://learnpythonthehardway.com/index These were both new ones to me, thanks for sharing! -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] An interesting situation befalls me
Now here is a chance to help influence this getting off on the right foot. > I can use recomendations for texts for use in an introduction to Python > class, and I will condense it down and provide them to the good doctor. > > -- > end > > Very Truly yours, >- Kirk Bailey, > Largo Florida > > Here are a few; Learning to Program by none other than Alan Gauld http://www.freenetpages.co.uk/hp/alan.gauld/ Essential Python Reading list http://wordaligned.org/articles/essential-python-reading-list Daves Page http://www.rexx.com/~dkuhlman/ -- David Abbott (dabbott) Gentoo http://dev.gentoo.org/~dabbott/ Podcast: http://linuxcrazy.com/ Web: http://nooone.info/ http://dwabbott.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor