Live data from Hacker News

Zed finishes Learn Python The Hard Way

sheddingbikes.com

71–80 of 115 posts

Re: Zed finishes Learn Python The Hard Way

#71
post #36
post #5

Unless I'm mistaken there's no chapter about functional programming in Python (lambda functions, filter(), map() and reduce()). I really think it's acceptable to introduce these function to newbies, I'll go as far as saying it's actually a good thing. I like the chapter on automated testing.

Meh. I just sent this to a friend of mine that knows nothing about coding, but is taking a class (biology) that uses python. She really has no need of functional programming, she just needs to know how to survive her problem sets. I think that's the audience.

Exactly. I taught programming, not dogma. Frankly, if I can teach two paradigms, and one is easy to explain while the other is hard, well I'm going to teach the easy one to explain.

Functional programming is just hard to explain to people who know next to nothing. Especially in a language like Python where the functional concepts are kind of half-assed.

Re: Zed finishes Learn Python The Hard Way

#72

Earlier quoted context omitted.

While I do agree those principles are useful, I think introducing those topics would diverge the focus of the book. I think the goal was of introductory nature not comprehensiveness.

There are some great beginner's books out there that barely cover functional constructs (e.g. PragProg's 'Learn to Program'). But I have always felt that such an omission is really a bad mistake. map/fold/filter introduce two very important ideas: - Higher-order functions - Many tasks are just list transformations What makes things more painful is that Java is so omnipresent in CS education. Since Java only contains…

"Higher-order functions, ... list transformations" you just said four words that are an entire book on their own.

Re: Zed finishes Learn Python The Hard Way

#73

Zed, May I suggest making it available in other formats, assuming that it is possible, once it is finished? Perhaps as text or HTML files in a tarball? Or even as an epub (for Nooks and iPad)?

Yep, the plan is to create a better site, offer the book on lulu.com in dead tree and ereader formats, and put it up in HTML format.

I won't do any of that yet though because I need to edit it and don't want people getting bad web pages from caches or places.

Re: Zed finishes Learn Python The Hard Way

#74
post #19

Zed, May I suggest making it available in other formats, assuming that it is possible, once it is finished? Perhaps as text or HTML files in a tarball? Or even as an epub (for Nooks and iPad)?

The source files are written in rst(ReStructured Text) format, the standard documentation format for Python. Specifically using [Sphinx]( http://sphinx.pocoo.org ). One of the default output formats IS HTML. Build instructions on *nix: $ fossil clone http://learnpythonthehardway.org lpthw.fossil $ mkdir lpthw $ cd lpthw $ fossil open ../lpthw.fossil $ make html $ open _build/html/index.html To install sphinx: $ easy_…

Please don't put it online in HTML just yet. I need to get it edited, and I'm afraid people will put versions of the book up in HTML format with errors and problems. Once the book is 1.0 then I'll have it online and anyone else can put it online. Can you take your link down please?

Re: Zed finishes Learn Python The Hard Way

#75
post #74
post #19

Earlier quoted context omitted.

The source files are written in rst(ReStructured Text) format, the standard documentation format for Python. Specifically using [Sphinx]( http://sphinx.pocoo.org ). One of the default output formats IS HTML. Build instructions on *nix: $ fossil clone http://learnpythonthehardway.org lpthw.fossil $ mkdir lpthw $ cd lpthw $ fossil open ../lpthw.fossil $ make html $ open _build/html/index.html To install sphinx: $ easy_…

Please don't put it online in HTML just yet. I need to get it edited, and I'm afraid people will put versions of the book up in HTML format with errors and problems. Once the book is 1.0 then I'll have it online and anyone else can put it online. Can you take your link down please?

I've taken down the doc.

Re: Zed finishes Learn Python The Hard Way

#76
Very nice. I just randomly choose to view the arguments unpacking section and found a defect (no example given on pg 36 for passing in only two args instead of all three, but later cited as "see how I passed in two args"). Created a ticket.

Re: Zed finishes Learn Python The Hard Way

#77
post #70

Earlier quoted context omitted.

You can also combine maps and filters in a list comprehension: suffix_str_lst = ['{0}_suffix'.format(x) for x in str_list if x[:4] == 'meep']

Read that out loud and tell me that doesn't grate on your ears? That's my basic test if code for the book would be understood by the reader. What you have here, this "symbol soup" is what makes programming hard for people in the beginning.

I actually find it really elegant. I fell in love with comprehensions as soon as I discovered them. They were the terse, expressive syntax I'd long been searching for.

Re: Zed finishes Learn Python The Hard Way

#78
post #72

Earlier quoted context omitted.

There are some great beginner's books out there that barely cover functional constructs (e.g. PragProg's 'Learn to Program'). But I have always felt that such an omission is really a bad mistake. map/fold/filter introduce two very important ideas: - Higher-order functions - Many tasks are just list transformations What makes things more painful is that Java is so omnipresent in CS education. Since Java only contains…

"Higher-order functions, ... list transformations" you just said four words that are an entire book on their own.

Sure, that's why Graham Hutton can do it in one chapter. Most books discuss lists and functions anyway, and from there is not such a big step to give an introduction to lambdas/closures, maps, folds, and filters.

It's not as if we are discussing monads (which are also easy to understand, given a good teacher).

Re: Zed finishes Learn Python The Hard Way

#79

Zed, May I suggest making it available in other formats, assuming that it is possible, once it is finished? Perhaps as text or HTML files in a tarball? Or even as an epub (for Nooks and iPad)?

Also, how about translating to other (programming) languages? Would you be interested in people porting the book, Zed?

Re: Zed finishes Learn Python The Hard Way

#80

Earlier quoted context omitted.

I thought the book was to be an introduction to programming through Python, that's a good opportunity to show "by the way, you can also see things the functional way...". I'm no Python expert, I couldn't say what's idiomatic or not. That being said, I never had the feeling of struggling with the language when using map and filter, quite the contrary. What's the idiomatic way of doing this? suffix_str_lst = map(lambda…

Probably to use a list comprehension: suffix_str_lst = [x + "_suffix" for x in str_lst] If you are okay with a generator instead of a list, then you can flip the square brackets to parentheses and then you do not need to hold the whole thing in memory at once. EDIT: You can add a filter in a similar way: suffix_str_list = [x for x in str_list if x.startswith("meep")]

Is there a tutorial on learning simple one liners like this? I find myself frustrated after seeing simple and obvious solutions like the above, but can never bring myself to code them as such.
Post reply on HN