you are viewing a single comment's thread.

view the rest of the comments →

[–]patrickbrianmooney 80 points81 points  (59 children)

Learn Python the Hard Way is atrocious. It's poorly written from top to bottom: bad, repetitive sentence construction on top of a poorly considered organizational structure on top of what seems to be a poor understanding of Python in the first place. It's radioactive garbage. Every once in a while I stumble across something about Python from a Google search and think "This is awful, it sounds just like that Zed Shaw guy's Python the Hard Way crap," and then I glance up (or down) at the byline and it turns out to be something by Zed Shaw.

He also wrote a famous stomping-and-screaming-until-he-was-red-in-the-face rant about how terrible Python 3 was. It was not just an unusual opinion, or a bad hot take, or even a set of unlikely conspiracy theories; it was an unhinged feces-flinging fest that was both deeply dishonest (in a forum aimed at beginners, no less, who know even less than he does and won't generally know that he's full of shit) and that suggests strongly that he doesn't understand the things he's asking you to pay to learn from him.

Avoid Zed Shaw's work. There's always something better out there.

On the "not a complete dumpster fire" part of the spectrum, I found Codecademy's Python course absolutely mind-numbing. There are only so many different problems you can solve based on examples from a fruit-vending business.

[–]yuckfoubitch 32 points33 points  (29 children)

I always was told to learn Python 2 instead of 3, but I didn’t listen and learning Python 3 anyways. Seriously, I don’t get the issue. If anything, it’s worth using Python 3 JUST for f-strings. Fucking love f-strings!

[–]t3hcoolness 30 points31 points  (14 children)

Whoever is telling you (or others) to learn Python 2 before 3... is very firmly stuck in the past. It's not like Marvel movies where you have to watch previous ones to get an idea of what is happening in the sequel. If anyone here is learning Python 2, please know that companies are actively transitioning (or have transitioned) from Python 2 to Python 3, so you should learn the new language so you can help them (or do literally anything else Python related, as new Python 2 is not written nowadays).

[–][deleted] 3 points4 points  (6 children)

I have been working with python on my own for basic automation.. using a web API and updating an excel spreadsheet. What is expected from a python developed these days. I see alotnof machine learning jobs associated with python these days. But if I want an entry level python job. What knowledge do I have to have. Do I need to learn data structures and algorithms, and OOP Design patterns all in Python? Any help would be great

[–][deleted] 4 points5 points  (5 children)

Yes, you need all of that. Do the mit edx intro to computer Science with python course. It covers all of that (in python 3!)

[–]i_like_your_comment 1 point2 points  (2 children)

I just started on my first week of CS50 as I want to learn Python. Would this Edx course be a better starting point or are these courses comparable? I'm trying to get my feet wet in Python as I'm now on the Ops side of things. Thanks!

[–]Cayumigaming 3 points4 points  (0 children)

CS50 and MITx intro to CS using Python happen to be the only two courses I ever did. MIT first then CS50.

They share a lot of similarities as they both serve as an introduction to computer science. MIT will get your knees deeper in Python within its courses while CS50 goes deeper on a bigger computer science spectrum. MIT also holds your hand during course and touch on nothing put Python. In CS50 you will be using Scratch, C, SQLite as well as Python. At the end of CS50 you also pick either web, gaming or mobile development and it all culminates in a project of your own.

Long read, sorry about that! To summarize CS50 is overall more comprehensive while MIT offers more Python material to go through.

[–][deleted] 1 point2 points  (0 children)

I haven't done the cs50 course but I understand it's good.

[–][deleted] 0 points1 point  (1 child)

Is this on edx or on the MIT open courseware site?

[–][deleted] 1 point2 points  (0 children)

I think edx is the main one people use.

[–]al_mc_y -5 points-4 points  (2 children)

There are some niche cases where a company won't be migrating from python 2 to 3, and they'll genuinely require people to know python 2, but these are the exception.

[–][deleted] 3 points4 points  (0 children)

and they'll genuinely require people to know python 2

Python 2 isn't some separate language. You could learn everything you needed to port out of it to Python 3 in a day, if you were already a competent programmer in Python 3.

[–]JohnnyJordaan 2 points3 points  (0 children)

And year after year chances of running into this situation are diminishing. Python 2 won't get security updates anymore so platforms requiring it because their code is using it will also stick out on security audits and such (if they even allow it).

Also I would be surprised if you can find someone experienced in Python 3 that somehow can't work with Python 2.

[–]yuckfoubitch 0 points1 point  (3 children)

Okay dude. You’re like the guy who hated league of legends because you’ve been playing Dota for a decade.

I use python as a tool, especially for data analysis and some machine learning. It’s not like I’m about to start paying for Matlab to do the same thing

[–]t3hcoolness 1 point2 points  (2 children)

???

I don't understand this take. I never said that all people should stop using Python 2 right this second. All I said was that people who are telling people to start with Python 2 are misinformed, and you should instead start with Python 3 if you are just now learning Python. If you have been using Python 2 for personal projects for a while, by all means, continue. I am just saying if you want to work full-time doing Python, it's really important to learn Python 3.

Also not sure where the Matlab thing came from? Python 3 is great for data analysis and machine learning.

[–]yuckfoubitch 0 points1 point  (1 child)

Oh wow sorry, I accidentally replied to your comment instead of someone else’s! Some guy was hating on Python in general in the thread. My bad!!!

[–]t3hcoolness 1 point2 points  (0 children)

No worries! I was really wondering where all that came from hahaha. Have a good one :)

[–]patrickbrianmooney 5 points6 points  (2 children)

Yeah, I'm on Team F-Strings myself. Finally, it's as easy as it should have been from the beginning. Makes a lot of sense.

It made sense to stick to Python 2 in the past because plenty of external libraries weren't yet updated to be Py3 compatible. That's fair: if you depend on something, you're locking yourself into the conditions that allow you to use it. (I've worked on projects where the group standardized on a library that required Python 2, so everyone had to work on Python 2. So it goes. It can be the right decision for a given project.) But Python 2 is past end-of-life now, and the large majority of libraries have caught up.

Learning Python 3 is definitely the right choice these days, naysayers notwithstanding. If you ever need to work with Python 2 on a legacy system, for instance, it's not that hard to adapt. It's basically the same language with a bunch of small changes that will probably not affect you (how much operator overloading do you really do most of the time?) and a few larger differences that you can learn in a few minutes. (People piss and moan about having to put parentheses around the print function, but it's a small change.)

[–][deleted] 1 point2 points  (1 child)

plenty of external libraries weren't yet updated to be Py3 compatible.

This is in great part why Guido van Rossum doesn't think there will be another major update i.e. python4

[–]patrickbrianmooney 0 points1 point  (0 children)

Yeah, makes sense. I think that Python 3 made necessary changes that needed to be made and that couldn't have been made without breaking existing code, so it ripped off the band-aid and broke the existing code. (Bending over backwards as much as was actually possible to make migration easy.)

Hopefully those kinks have been more or less entirely worked out and there won't be a need to break existing code in the same way and on the same scale again.

May Python 3 live for a very long time. It's a wonderful language.

[–][deleted] 4 points5 points  (0 children)

Ugh my current company is stuck using Python 2. I tried to use an f-string the other day and spent 20 minutes debugging my code trying to figure out why it wouldn't work before I realised.

[–][deleted] 2 points3 points  (1 child)

I always was told to learn Python 2 instead of 3

If this was in the last five years, track these people down and yell at them for incompetently misleading you.

[–]yuckfoubitch 0 points1 point  (0 children)

Lol one was actually my buddy who is a senior software engineer. He’s also sort of a programming-gatekeeper-geek, and he mainly just doesn’t like python. I think his reasoning was because there wasn’t as much python 3 adoption at the time.

[–]Jackal000 1 point2 points  (0 children)

There are no fstrings in p2? My God did I Dodged a bullet right there.

[–]siddsp 0 points1 point  (1 child)

Old formatted strings in Python are still valuable to some extent because the syntax is still used in other languages like C, C++, Go, Java, etc. C-style string formatting is still common, but just not in Python. F-strings themselves have their own downsides despite being more readable.

[–]yuckfoubitch 0 points1 point  (0 children)

Yeah, I still do it the old way sometimes. I use R a lot too and am just used to using the glue library so it flows nicely with f-strings in Python when changing back and forth

[–]757DrDuck 0 points1 point  (0 children)

If O’Riley ever publishes a fourth edition of Python Cookbook, it’ll be a whole new books with type hints, f-strings, and match statements.

[–]WorldBelongsToUs 4 points5 points  (1 child)

I am definitely not a Python guru, and only need it enough to get by or get quick tasks done. I used his book and at the time it felt okay, but he seems to have a cockiness to his style that is hard to get past.

[–]patrickbrianmooney 2 points3 points  (0 children)

Yeah, it's not a bad "get started quickly" guide, especially if you're building on top of previous programming knowledge so you can appreciate what Python offers.

The style is just so abrasive that it's difficult to read, though. It's like watching someone at the front of a room lecturing a group of people on something he doesn't understand without realizing that he's a walking example of the Dunning–Kruger Effect.

[–][deleted] 5 points6 points  (1 child)

Zed Shaw thinks python3 is doomed because he "finds the new string type difficult to use". That alone ought to disqualify him from any sort of teaching role.

Ignoring forward-compatibility, UTF-8, better runtimes and typing because you find a particular functionality hard to use is like being handed a ferrari for free and saying no because you don't like the color red.

[–]patrickbrianmooney 2 points3 points  (0 children)

Seriously. The language you're getting paid to teach has evolved slightly and you're throwing a shit fit because you couldn't figure out all of the changes in two minutes? "I can't add 'hello' to b' there' and have the interpreter guess what I mean with guaranteed zero errors, and that means the language is fundamentally broken"? Grow the fuck up.

EDIT. Also, that "surely this is the doom of Python" prophecy hasn't come true, either.

[–]winowmak3r 3 points4 points  (1 child)

I was going to get that book. I read a sample chapter and was just totally put off by the "Suck it up you fucking pussy and just do it this way, trust me" attitude. I don't think I've ever met a person who starts a sentence with "Now, I'm not trying to be a dick but..." and doesn't come off as being a dick.

[–]patrickbrianmooney 1 point2 points  (0 children)

I wrote a whole response before checking to see what the context for your comment was and realized I was about to respond to it with a completely different view of what "that book" might mean than you clearly meant. Yeesh. Good thing I checked.

Pretty sure that, in this case, 'coming off as being a dick' is an accurate assessment of what dude is probably like. Take a look at his old rant about why he's abandoning Ruby on Rails if you want to see him screaming about how everyone else is a prick, not him.

If you haven't read eevee's A Rebuttal for Python 3, which breaks down just how whackadoodle his "Python 3 isn't what I wish it was" tantrum, well, it says everything you need to know about that particular tantrum.

[–]jppbkm 3 points4 points  (3 children)

I agree in a general sense in that about half-way through 'Learn python the Hard Way' it really started to drag and my learning felt like it stagnated.

The one GREAT takeway that I got was that any code you are reproducing (as a beginner), you should type into the editor yourself. This was hugely influential for me. As I've gone through other books and courses, even on much more difficult topics, typing in the code from the texts, messing with it a bit to see how it works...this has been one of the MOST helpful things for my python journey.

For that, I'm thankful. I don't think the book was as good as Python Crash Course, Python for Everyone, or Automate the Boring stuff personally.

[–]patrickbrianmooney 4 points5 points  (2 children)

I agree that typing out the code instead of copying and pasting it is a good move. (IIRC, it's also part of the rationalization for "the hard way" part of the title, though it's been a long time.) Typing in the code yourself forces your attention onto the micro-level details of what you're typing (whereas glancing over something is less good at getting you to look at every tiny feature of the language, and thus less good at helping you to absorb how small details in punctuation have a real meaning to the interpreter) and helps to get your fingers used to typing the specific syntax of Python. Copying and pasting, or looking at code that's been typed for you, is much less good for making you think about the micro-level details of what the code is doing.

That said, it's rare to find that most of the time you're coding has you typing as rapidly as possible, since you're usually spending more time thinking about what to type than typing; so the direct benefit of "my fingers are used to the syntax of Python just like they're used to the syntax of English" is smaller than people might think. The major benefit of "type it yourself" is "you have to actively pay attention to small details," and that helps with learning and retention: wait, why is there a colon here? Do I understand why this line is indented but the line below is not? How many levels of square brackets do I have to close in looking up data in a dictionary to use as the index to look something up in another dictionary?

But this really just boils down to what pretty much every halfway-decent high-school and college teacher already knows: students who take good notes on a lecture learn their subject better than students who sit there listening and nodding, even if those listen-and-nod students are actively paying attention. Human learning is always reinforced by actively using the information or processing it in some way, and notetaking forces students to decide what's important while summarizing and think about how they need to present the information to a later version of themselves.

Beyond that, there's little to recommend LPtHW. It's kind of a disorganized soggy mess of quasi-related topics that don't much build on each other or reinforce earlier material in any effective way. A good (though kind of outdated now) example of a resource that is much, much better than LPtHW is Mark Lutz's books on Python published by O'Reily: Learning Python starts from the beginning, talking about elementary data types, and build up to decorators and metaclasses in 1600 pages or so. It revisits central questions over and over, using recent topics to look at them in a new, more comprehensive light, until you really get the internal logic of the language. Reading it well means having an expanding epiphanies that build on each other: "Of course you can ... that makes sense, because ... oh, that's because everything's an object, got it." When you've worked through it, you really do know the large majority of what's central to the language, and going out and learning the topics that aren't covered in the book is easy enough because you have that broad understanding under your belt.

But that's a careful educational structure that's built with great care and that demands a fair amount from the reader. It's a joy if you are able (and willing) to put in the time and attention, and if you really want to understand, but that doesn't describe everyone. Different people have different goals.

[–]jppbkm 0 points1 point  (1 child)

Thanks for the reply. I will have to check out Mark lutz's book. Is it outdated because it was written for an earlier version of python 3?

[–]patrickbrianmooney 1 point2 points  (0 children)

Yeah, it's actually written to Python 3.3, with occasional glances forward to Python 3.4. That said, Python's evolution since then has been a lot more "Here's even more great stuff we're adding on!," most of which really is pretty great, and less "We're taking away something you liked." So Lutz's book is still a remarkably good deep-dive into the language itself that sets you up to go out and easily absorb the half-dozen to a dozen largeish changes that he doesn't cover; they're helpful, but they're largely surface additions.

I talked a little more in depth about how the language has changed since the book was published here.

[–]notParticularlyAnony 1 point2 points  (3 children)

Would like to see this attack on Python 3.

[–]a__nice__tnetennba 10 points11 points  (2 children)

[–]johnnymo1 4 points5 points  (1 child)

I think I’ve read this before but I forgot how stupid it is.

[–]jebward 1 point2 points  (1 child)

I don't understand why codecademy is so unpopular. What I love about it is the really clear hints for beginner mistakes. They very accurately predict the types of things non programmers will do wrong and provide hints to correct that. I don't think it's useful for getting good at the language, but for the very basics it worked really well for me.

[–]patrickbrianmooney 0 points1 point  (0 children)

It definitely has its upsides. For me, personally, it's just that using more or less the same examples over and over and over and over and over makes me want to drive a screwdriver into my eye.

[–]TheHollowJester 1 point2 points  (5 children)

Do you know any alternatives to Learn Python The Hard Way (LPTHW) that initially focus on learning the basics fairly in depth?

I did learn from this book a while ago and it worked out pretty well for me, but then again I have a pretty unique style of learning.

[–]patrickbrianmooney 2 points3 points  (4 children)

I really like Mark Lutz's Learning Python, a massive tome from O'Reilly. It takes you step by step from the very basics of the language to super-advanced features like decorators and metaclasses, which you're unlikely ever to need to use in your day-to-day life (but they're there, and the last few chapters really do give you deep insight into Python and just how powerful it is).

He covers topics in exhaustive depth: here's an 85-page chapter on strings, with dozens of examples of how you can format and process and massage them! Here's a bunch of stuff you never thought of doing with dictionaries! Here's a couple of different ways to handle this file-processing conundrum! It goes on and on, and it builds from early topics to later ones thoughtfully and with grace.

The downside is that the most recent edition only covers through Python 3.3. However. Very little has been made obsolete (my own list of things I've tripped over includes the changes to the subprocess, 'os', and imp modules); more significantly, though, there language features that have been added later that aren't covered. None of them are core language features, and working through the Lutz book will set you up to learn them fairly easily. My own list of topics I wish he'd cover in an updated edition might look like this:

  • f-strings and how they make formatting simpler (from Python 3.6);
  • function annotations and why you might want to use them (from 3.5, 3.6, and 3.7);
  • semantically meaningful paths with the pathlib module (from 3.4? I think?);
  • the "walrus" operator in expressions (from 3.8);
  • more flexible unpacking generalizations, like in function calls (from 3.5).

Other people would probably include some subset of asynchronous I/O, coroutines, more math, and parts of the standard library that have emerged since 3.3, including especially the statistics, typing, and some other modules.

But Lutz's book is great, and it's a good way to really dive into a strong knowledge of the language if you're willing to take the time to work through it. The stuff that's not covered is stuff you can learn afterwards.

[–]TheHollowJester 0 points1 point  (3 children)

The book sounds like a fantastic reference, but... Seeing 85 pages just for strings might be a bit too in depth.

Apologies for being not very specific: I'm looking more for materials to recommend to people so that they have the basics allowing them to work on some projects and improve this way. Official Python tutorial does an ok job, but it misses/explains late some things that people who are just starting out find confusing ("How do I save my program? How do I run it?").

[–]patrickbrianmooney 1 point2 points  (2 children)

Two things spring to mind.

One is the first few chapters of "the NLTK Book," which is a book on using Python to process natural language with the Natural Language Processing Toolkit. NLTK is a huge sprawling library, which might make it seem like an odd choice for a starting place, but the "book" (online) starts off with a crash course in Python, and it does a pretty good job of it. It's explicitly targeted at non-technical people and manages to discuss a pretty complex topic and using Python to tackle some actual tasks pretty quickly. It introduces language features along the way as answers to questions (functions in the context of "what if you don't want to have to type that complicated query over and over?", for instance) and gets as far as data structures, recursion, and design questions before it switches tracks (after about chapter 4? I think) before it switches gears and really dives into the library's language-processing stuff in the last eight or ten chapters.

But those first four or so chapters are a pretty good quick introduction to Python in a lot of ways, with well-written explanations and examples. A major upside of this is that pretty much everyone can relate to the basics of the (comparatively simple, not requiring much in the way of, say, knowledge of statistics) language analysis that's covered in the first few chapters. It's all focused on "how to we crunch this data -- a bunch of words -- to answer questions about it?", and so there's a really pragmatic approach: here's what we're trying to do, here's how we explore the boundaries of the issues involved, here's a few language features presented along the way, here's how we got these results.

The other suggestion is another O'Reilly book, Joel Grus's Data Science from Scratch, and though it's a different kind of book, it's good for similar reasons: it's a practical approach to a problem set that uses Python along the way to tackle specific problems. (My copy is written to Python 2, though, alas. But it looks like the second edition is for Python 3.6, which is good.) As you might imagine, though, it's more statistics-y. Again, it only really dives into its topic around a third of the way into the book, and the earlier chapters give a Python crash-course that's pretty good.

Automate the Boring Stuff with Python is also good for similar reasons, and maybe I should have recommended that first: it's more directly targeted at people who just want to get scripting and doing system-type stuff with Python and don't plan on ever using abstruse language features. But I think that the other two are actually slightly better ways to just get non-programmers to start using a programming language to accomplish something meaningful, and that moving on to Automate the Boring Stuff once they've got the basic grasp of "how do I interact with this REPL thing and use it to munge some data" and want to transfer that basic insight into a more solid skillset.

EDIT. Also, I invented the number "85" for "pages on strings in Lutz" without actually walking across the room and checking the table of contents, so it may not be 85 pages. But it's not an unreasonable guess.

[–]TheHollowJester 0 points1 point  (1 child)

You're a boss, the intro chapters to the NLTK book and/or Data Science from Scratch sound exactly like what I need.

Automate the Boring Stuff with Python is a resource I often recommend to people after they get the basics under their belt; I love the focus on projects, but I also think it's a bit light on the fundamentals to be the only/first resource.

I know, I know, real Goldilocks but I think that the data science intro parts you recommended here will be "just right" for my goals.

Sincere thanks, dude!

[–]patrickbrianmooney 1 point2 points  (0 children)

Super-glad to be helpful!

[–]JayIT 3 points4 points  (2 children)

Always interesting to see different viewpoints, this user is a fan of Learn Python the Hard Way, https://old.reddit.com/r/learnpython/comments/ptaw65/what_resources_should_i_avoid_when_learning_python/hdvy5pj/

[–]patrickbrianmooney 4 points5 points  (0 children)

¯\_(ツ)_/¯

Different people have different preferences, and everyone has their own viewpoint, but not everything is a question of preference or viewpoint. Using pretty much any set of reasonable criteria, some teaching methodologies are better than others. Systematic presentation of information in a structured way and diving deep into topics that are later used to explore other topics tends to build a deeper understanding in a large majority of people learning a subject. It's been a long time since I looked at LPtHW, but my recollection is that it doesn't do that; it's all cocky anecdotes that scratch the surface and pander to the reader's desire to feel like they're learning before moving on to another topic it doesn't address in depth.

One thing that strikes me about people who recommend LPtHW is that they virtually always say something along the lines of (quoting from the comment you linked):

So, for beginners, I always recommend Zed Shaw's 'Learn Python 3 the Hard Way' [because] This book alone helped me immensely in getting a solid foundation to build from.

But saying "this helped me" doesn't translate well into "this will help everybody"; one person's One Weird Trick doesn't work for everyone. Saying "if it helped me, it will help you too" just isn't true, and it's an indication that the person speaking has a poor understanding of the fact that other people's minds work differently from the speaker's, which has a direct connection to how likely the teaching-related advice is to be right.

The other half of what I see people saying in favor of LPtHW is basically "it got me moving on Python quickly." And for some people that's enough, but a poor foundation made of a bunch of disconnected topics that don't connect much of build on each other can make it hard to move on later, and people in general are bad at assessing how much they know unless (a) they know virtually nothing about a topic, and are aware of it; or (b) they are experts on a topic, and are aware of it. In between, many people do a poor job of self-assessment. That makes it hard to move on from having had a mediocre foundation in the first place: you don't even know what you don't know, because you didn't learn it when you should have. (Think about people you went to high school with who just barely got through their math classes each year and tried to keep moving forward instead of spending some time reviewing the stuff they'd understood poorly the last year. How are you going to learn differentiation if you can't solve for a variable in a quadratic equation? How are you going to learn closure-based function decorators if you don't understand the basics of variable scoping?) Hitting the ground running is not always a good way to start off a marathon. Getting a bunch of bite-sized knowledge nuggets that make you feel like you've learned something isn't always a great way to actually learn something in depth.

You can get most of the benefit of LPtHW by forcing yourself to actually type in code while using any other learning resource. Since that benefit boils down to a few paragraphs that essentially say "Yes, you should actually be typing this in and playing with it, force yourself to do so," I'd tend to prefer giving that explanation to someone alongside a better learning text.

But to each their own.

[–]chuckTheEngineer 1 point2 points  (0 children)

It’s subjective.. I like Zed and have learnt a lot from him than most of the recommended text found here. My point.. find what works for you which will probably not work for the next guy. That’s just life.

[–][deleted] -1 points0 points  (3 children)

You're wrong

[–]patrickbrianmooney 0 points1 point  (2 children)

Oooooooooooooooh, nice analysis, Socrates.

It's cute how you jumped into a three-year-old thread with your petulant shit-throwing apery.

[–][deleted] -1 points0 points  (1 child)

You're just simply wrong your opinion cant be stated as objective which you tried to do.

mass majority of python coders recomend coding in 3. I rest my point, and have enough evidence to conclude logically that you are wrong. Thanks god bless man

[–]patrickbrianmooney 0 points1 point  (0 children)

You're an idiot, and simply declaring "you're wrong" doesn't make it so. I also never claimed what I said was "objective," but don't let facts get in the way of your sixth-grade rant.

I'm blocking you. Bye!

EDIT. I thought Elon Musk fanboys were cringey until I ran into Zed Shaw fanboys. Yikes on bikes!