37 ms·
Learn Python 3 the Hard Way
- happy-go-lucky 10y agoPython 3.x is the present and future of the language
- throwaway7645 10y agoA language I use daily and love, but one that will end up a dead-end I fear long-term. So much is going the way of speed now.
- leblancfg 10y agoI'm not sure I get that. Care to elaborate, and what use cases you have for it?
- throwaway7645 10y agoOO I'd love to, but you'll have to take it with a grain of salt :) Python is wildly popular now, and it is great for small scripts and interactive data analysis, but I don't see any real long-term strengths. It is not growing and is very slow in comparison to most languages. There are soooo many interesting projects out there. Perl6 is very immature from an implementation perspective, but is just as easy to use as Python, but has waaay more power and flexibility under the hood. The OO model is more advanced, the semantics are clean and elegant, you can do real FP, easy asynch based off of C#, grammar based programming...etc. Python can do a lot of that with modules, but having it all in one consistent package is nice. On another note, there are sooo many languages that although maybe not as flexible as Perl6, they run blazingly fast. Think of Crystal (Ruby syntax with native speed and no dependencies), Dlang, Go, Rust, Red (fast and dynamic language in a 1.3 MB runtime...you can even access a systems language DSL...the best GUI system I've ever seen). So basically we have new languages that have the advantage of an easy syntax like python, but are waaay faster and not mostly locked in place (Guido doesn't like feature bloat). There is also Elixr...etc. Python isn't dead, but I don't think a JIT is enough at this stage and I'm mostly moving on. Python's hold on scientists is being challenged by Julia which will be just as easy to use, but also once again...much faster. Let's not forget that C# is actively maintained by a large and very well funded team at Microsoft and is constantly adding new features like LINQ and now things from F#, which is a great language on its own. I don't take Haskell seriously. Note that I think it is very advanced and can be quite fast, but it is also very hard for most people to understand things like Monads (just Monoids in the category of Endofunctors...wtf) or Currying...etc. I expect Python to remain around for a very long time (you can still find Cobol at banks and I rely on Fortran every day, but I really hope it is not still in the top 5 on the Tiobe in 10 years unless Python 4 is a rewrite from scratch to have a few more features and run on LLVM...oh wait we already have Nim that is basically Python syntax transpiled to C & then compiled with gcc or clang to get ~40 years of optimizations. My uses for python are data analysis, helper scripts, command-line apps, glue on Linux servers, glue on windows where it acts as a better CMD (I've tried powershell, but I don't gain much and often lose in speed as 8/10 ways to do something work, but are dog slow).
- hueving 10y ago"All the features" is why perl is considered a write-only language. It's great for personal projects but I have yet to see any big successful perl projects because the onboarding time of learning a given perl project's chosen features is so cumbersome.
- throwaway7645 10y agoIs that serious? Lots of massive perl projects out there like Booking.com. If you search you can find an article on how they manage their +1 million plus line code base in production. It can definitely get unwieldy I bet, but you can write really good code too. I don't think having extra features makes a language bad as long as it isn't all bolted on and the community has some discipline.
- hueving 10y agoA large commercial project is not the same thing. You can use whatever hideous language you want for that because you are literally throwing money at your developers to make them understand and work on the code base. The bar is large open source projects, which indicates that it's very easy for a drive by developer to isolate a bug and fix it or implement a feature.
- throwaway7645 10y agoPerl5 by itself is a pretty large open source project as is all the 25,000+ CPAN modules, but you're correct that I'd rather not deal with the Perl5 VM itself as that is probably very arcane (although I've certainly never tried). That could just be because the language has 30 years of open source patches on it. Perl6 on the other hand was designed to be stupidly easy to get into fixing the Core and VM. Instead of being written in C, it is written in a limited Perl subset "NQP" or "Not Quite Perl" that is much easier to read. They've had several blog posts about tracing an error pack to the source and fixing it. I'm not sure if P6 will continue steaming ahead into a true production language, but i really hope it does as it is so nice.
- crdoconnor 10y agoI doubt that. Most of the cited competitors to python are either seriously flawed (e.g. go) or aren't really competing on the same turf (e.g. rust/haskell).
- verandaguy 10y agoSpeaking as someone who really loves Haskell -- let's be real, it's not serious competition against Python or Rust, same turf or not. It's a fantastic language for numerical computing and its applications, and for compilers/parsers, but it's never going to be as easy to use for the layman as an imperative language. As someone who's used Go and who has some mixed feelings about it, I'm curious -- what do you find flawed in it?
- raverbashing 10y agoGo is not flawed (I mean, of course it has issues), but it's not the same thing/area
- verandaguy 10y ago> Go is not flawed For most technologies (with some notorious exceptions) that boils down to a matter of opinion an intended use cases.
- crdoconnor 10y ago>what do you find flawed in it? * Package management * The weird and approach to exception handling (which leads to overly verbose code) * Lack of generics (which leads to overly verbose and somewhat hacky code) * Vastly smaller 3rd party ecosystem I think it works well for a very small subset of sysops-style problems (small servers, small command line tools, etc.) especially since it easily compiles into one small, portable binary, but outside of that it flounders.
- verandaguy 10y agoThanks for following up! Those are some of my gripes with the language too. The vendoring system/would-be package manager especially has caused me hours of headaches, and I'm glad to hear I'm not the only one who considers it broken.
- vonklaus 10y agoPG was talking about viaweb and dead languages in an interview I won't spend 10mins looking for; but he said something like: Latin is a dead language and no one speaks it. Sure it is helpful for understanding other languages, but I never got that comparison because the computer always speaks it. Certainly imperfect paraphrase, but the crux is that you can always code python, or lisp ect.
- daveguy 10y agoFor those who want an alternative there is the community continuation of Python 2.8, called Tauthon: https://www.naftaliharris.com/blog/why-making-python-2.8/ https://www.naftaliharris.com/blog/why-making-python-2.8/
- raverbashing 10y agoThose that go on this path will then find out they have gained nothing and only lost time by not updating their systems
- vegabook 10y agoand many (like me) who have painfully moved to Python 3 will find that they have gained nothing important there either other than avoiding the "end of life" blackmail.
- raverbashing 10y ago> avoiding the "end of life" blackmail People usually think that costs nothing, until they get bitten by it.
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- crncosta 10y agoThis guy has a very stranger way to promote his job. He firstly said that Py3 sucks and he can't teach it... and now he is teaching it ;-) [0] https://learnpythonthehardway.org/book/nopython3.html https://learnpythonthehardway.org/book/nopython3.html
- iodbh 10y agoWhich turned into a big internet fight, and he changed his mind. It's good to see people willing to change the way they do things, especially when that means publicly contradicting their former selves and with such an intense personality. It's oddly inspiring.
- jhbadger 10y agoAlso, when he wrote it was kind of true. A lot of things hadn't been ported to Python 3 yet and using it was asking for pain. Now finally we are in the opposite situation where many things are ending support for Python 2 and the easier route is Python 3.
- thehardsphere 10y agoHe wrote his rant a few months ago, which was well after every major library switched to Python 3. Dunno if you mean his previous book or the rant where he said, among other things, that Python 3 wasn't turing complete.
- jhbadger 10y agoHe updated it a few months ago, but he's had versions of this for quite some time. Yes, maintaining it in late 2016 is somewhat stubborn, but it made a lot of sense in the early years of Python 3.
- thehardsphere 10y agoI have a difficult time believing that we're talking about the same rant, because the one I'm talking about would not have made any sense even in the early years of Python 3. Oh, I see it's been updated with a sober disclaimer now, where "In the previous version I trolled people" and "I even had a note after the gag saying it was a gag, but everyone is too stupid to read that note even when they do elaborate responses to my writing." I read his writing very carefully. This note didn't exist.
- dv35z 10y agoRelated: I love this book's teaching style, and found it very much resonated with me - starting from zero, step by step, iteratively learning and building on previous lessons. Can anyone suggest something similar for learning Scala?
- solaris999 10y agoThe canonical source for learning Scala from scratch (at least, when I was learning a couple of years ago) is the Coursera course by Martin Odersky, one of the language's founders. It appears that the course has grown somewhat, but you can still find part 1 here: https://www.coursera.org/learn/progfun1 https://www.coursera.org/learn/progfun1
- dv35z 10y agoI took the course - unfortunately, and to be honest, it didn't have the approachability and "fun" of Zed's books. To me - it felt very dry, academic, and quickly became a chore to complete rather than a joy. I need the version aimed for "C- python programmer" / newbie rather than "eager CS student" or "experienced Java dev".
- blacksmythe 10y ago>> Coursera course by Martin Odersky Brilliant course. Unfortunately, the next one in the series is not nearly as good.
- lmm 10y agoAtomic Scala is what I hear recommended for starting from scratch - I can't truly speak for it myself as I knew Scala before it came out, but I liked what I saw of it.
- dv35z 10y agoThanks - will check that out.
- garysieling 10y ago
- Sir_Cmpwn 10y ago>I've standardized on this version of Python because it has a new improved string formatting system that is easier to use than the previous 4 (or 3, I forget, there were many) Wait, is this seriously the only advantage you see to Python 3, Zed?
- empath75 10y agoI think he hated the old python3 string formatting and that was why he didn't cover python3 previously. The new version is good enough that he's willing to make the switch now.
- Vaskivo 10y agoMaybe in the context of the book it is a major reason. Strings are ubiquitous to programming. I'd argue that it's even more for first time programmers. Zed wanted something that would be easy to use. (ASCII) Strings formatting is more important to beginners than unicode support, new style classes by default, iterators in range()/enumerate()/etc. , the new division operator, etc. I haven't recommended his book to beginners because it was stuck in Python 2. But I have to agree that Python 2 had some stuff that was more "newbie-friendly" than Python 3
- Sean1708 10y ago> But I have to agree that Python 2 had some stuff that was more "newbie-friendly" than Python 3 What stuff, out of interest? Also I suspect that a huge proportion of newcomer's got very confused as to why 3/2 == 1.
- Vaskivo 10y agoYes. But that is easy to explain. "It always rounds down" Of the top of my head come the range/enumerate/zip returns. They are really useful and needed to teach "pythonic Python". But it's hard to explain that it doesn't return a list. "It returns an iterator, that is lazy, and you need to call 'list()' on it to use it as a list..." You get my point. You fall to a "just do like I told you. You'll get it later." that plagues a lot of other languages when being taught to newbies. But I never said that Python 3 is less "newbie-friendly" than Python 2...
- diimdeep 10y agoNot hard enough. Try https://lectures.quantecon.org/py/ https://lectures.quantecon.org/py/
- happy-go-lucky 10y agoIs that for quants? Seems to be good. Thanks for the link.
- ChristianGeek 10y agoNo kidding. Thorough, too...the PDF for the Python lectures is 862 pages!
- happy-go-lucky 10y agoThat's great. In fact I submitted it here at https://news.ycombinator.com/item?id=13724295 https://news.ycombinator.com/item?id=13724295
- nullgeo 10y agoThanks for posting this :)
- fredley 10y agoIntroductory example 1: Plotting a White Noise Process > Suppose we want to simulate and plot the white noise process ε0,ε1,…,εTε0,ε1,…,εT, where each draw εtεt is independent standard normal
- tbranyen 10y agoIf this is anything like his Learn C book, I'll pass. Was a waste of money as he came off incredibly arrogant and fumbled through it.
- dagw 10y agoAt least the original LPtHW was quite a fundamentally different book from his learning C book. The C book was aimed at people who knew at least the basics of programming in some other language and wanted to learn C, while the Python book was more aimed people who had never programmed at all.
- oliwarner 10y agoYou'll either love or hate his style but one thing you should note is that popular current production distributions are pegged on older versions (eg Ubuntu 16.04 has Python 3.5, Debian Jessie has 3.4. If you're a purist and don't want to maintain your own build of Python (or trust an external PPA), I'd aim at 3.5. That said, this is about learning... But you'll need to learn not to use f-strings if you want to use it on a current-generation LTS distribution.
- mixmastamyk 10y ago3.6 is in the repos for yakkety as a beta, and upcoming release on zesty. Unfortunately it will likely not be the default Py 3.x until the "aardvark" release.
- oliwarner 10y agoI'd advise against using 9m support distributions in production though. It's a super pain in the arse to have to do major upgrades that often.
- mixmastamyk 10y ago9m?
- oliwarner 10y agoSorry. Nine months. That's all the non-LTS versions get.
- deleted 10y ago[deleted]
- lima 10y agopyenv is great for running whatever Python version you like: https://github.com/yyuu/pyenv https://github.com/yyuu/pyenv I'm a strong believer in de-coupling base system and application deployment. And if you're a CentOS user, you can get newer Python releases from https://www.softwarecollections.org/en/scls/?search=python https://www.softwarecollections.org/en/scls/?search=python (an official Red Hat project)
- drops 10y agoFor a beginner who wants to learn Python, which one is better — 2 or 3?
- bnchrch 10y agoDefinately 3.
- satysin 10y ago3. When you need to work with a 2 code base the learning curve won't be big at all. Whereas if you start with 2 and then move to 3 you will have to unlearn a bunch of stuff which is just a waste of time. Start with 3 and then learn just the differences in 2 when/if you need them.
- cgriswald 10y agoAgreed. Just as a for-instance: In Python 2, the parenthesis on a print call are optional. In Python 3, they're not. Going from 3 to 2 you probably won't even notice. Going from 2 to 3... To this day I often fail to type those parenthesis.
- deleted 10y ago[deleted]
- pvg 10y agoDefinitely 3 and almost certainly not from this book.
- QML 10y agoIf you want to learn a language efficiently, work on a project with it. I went through Learn Python the Hard Way pretty fast but my retention wasn't that great.
- johansch 10y agoLearn Go instead.
- fnordfnordfnord 10y ago
- IshKebab 10y agoI'm not sure I would recommend learning Python to anyone these days. Go is just so much nicer and almost as easy, and also avoids the inevitable GIL & speed problems.
- bkbridge 10y agoIf you are doing AI, machine learning, it's all Python. Other language support yes, but python is it. Alexa does not support Go. > https://www.tensorflow.org/ https://www.tensorflow.org/
- vegabook 10y agounfortunately this is true. For one thing Go doesn't have a REPL - major problem for data science/AI/scientic programming. And it's very committed to old-style procedural/imperative paradigm. Numpy is carrying Python, and its competitors are thin. There's Julia, but that's not really ambitious enough compared with Numpy to be worth moving to. There's Scala though then you need to love the JVM. Lua had promise as a nice and tight, pragmatic and fast language, but it seems to have missed its window of opportunity. What else? I'd genuinely like to know. Ideally I'd like something that's got a functional programming flavour but that also data-parallel, almost R-style, by default, so as easily able to target the GPU. I took a look at futhark but it seems too experimental, as does Ocaml/spoc combo. I am taking a serious look at the probabilistic programming area with Edward or Stan, but then we're back to Python front ends.... Actually I did look at Swift which does c-class speed with an official REPL but an apple-supported language may not attract the science/ML crowd. Meantime rust is REPL-less for now...
- kstrauser 10y agoNot to mention that Jupyter (was IPython) is a gorgeous way to work through a dataset while describing your process to your peers.
- StreamBright 10y agoYou mean the API that you are calling is in Python. I think the heavy lifting is mostly C/C++.
- PuffinBlue 10y agoKnew it was coming, but still kinda annoying right in the middle: https://josharcher.uk/categories/lpthw/ https://josharcher.uk/categories/lpthw/
- systems 10y agois this complete or a work in progress, because if you try to buy, you can still only buy the 3rd edition (with a free upgrade to 4th edition) so to be clear, is the online version complete, and only the pdf and videos are missing, or even the online version is still work in progress
- BuckRogers 10y agoPython3 folks act so daft about his Turing-complete comments. ZS knows what Turing complete is and means. He was clearly trolling, saying in essence, "if the CPython team can't create interop between CPython2 and 3 code then they really botched the job.. Python3 bytecode is Turing incomplete. What a fail." And then people attempt to troll him saying he doesn't know what Turing complete is. Perhaps they really don't understand what they're even responding to, that's what it appears. Or it's just a willful attack because they "like Python3". Unfortunately with Python3 this is what the Python community has been slowly devolving into, what comes off as a bunch of trolls/kids or ridiculous adults.
- thehardsphere 10y ago1. I'd really like to see proof that the people he was trolling actually existed, and if they did exist, a coherent explanation of why beginners to Python needed to be exposed to the arguments of said people through trolling. 2. Zed can troll people, and that's totally OK, but the "like Python 3" people can't troll him or counter-troll him, because it's turning the Python community into trollville. I'm guessing like sort of how Rails is a ghetto.
- vonklaus 10y ago> I'd really like to see proof that the people he was trolling actually existed See the user of this parent comment.
- thehardsphere 10y agoI have never asserted that Python 3 can never run Python 2. The claim is that Zed trolled some imaginary people who said this.
- siddharthgdas 10y agoIf you are a complete beginner in python, I would rather suggest this for python3 - www.openbookproject.net/thinkcs/python/english3e
- alexeiz 10y agoZed lost his credence. It's hard to take him seriously after what he's said in the past. Besides, the book is rather light on content.
- rattray 10y agoFor those of us who are late to the party, what did Zed say in the past?
- renesd 10y agoIt's actually harmful to point newbies towards his work. There are much better resources that have been proven in practice to work better.
- dfabulich 10y agoSuch as?
- dtornabene 10y agowell, you can go with the actual python tutorial for one. Or the literally dozens of intro to python books put out by No Starch, O'Reilly, Packt, Wiley, etc. You can also go with some of the classics like Swaroops' Byte of Python, or any of the college lecture notes. I hesitate to suggest this, but its worth saying, the book that Zed shit on to launch his little franchise is still actually usable (especially just to read the code examples) and was a much much much better book in terms of pedagogy then his tedious, arrogant offerings.
- throwaway7645 10y agoYea...flipped through Zed's book. It seemed alright, but Python Programming for the Absolute Beginner is an amazing piece of work. Crystal clear, and you get to build fun little text games.
- systems 10y agothink python http://greenteapress.com/wp/think-python-2e/ http://greenteapress.com/wp/think-python-2e/
- jorge-fundido 10y agoI tell people to `ipython; %magic`. For all of python's faults, that REPL is the gold standard and makes for a nice way to learn the language.
- pbreit 10y agoWould a tutorial like this really be worse if it used realistic situations?
- mistaken 10y agoThe hard way is still the easy way though. Python is simple to learn :)
- edgartaor 10y agoIn your opinion which one is better? Learn Python the hard way or Dive into Python 3 http://www.diveintopython3.net http://www.diveintopython3.net
- deleted 10y ago[deleted]
- Orangeair 10y agoA lot of people dislike Zed Shaw's books (the author of Learn ___ the Hard Way) for various reasons, and he has posted some things online that serious call into question his credibility (namely, claiming that Python 3 is not Turing complete). Dive into Python 3 is a good book. I used it to supplement my CS classes in early college. There are some other good book suggestions on the sidebar of https://www.reddit.com/r/Python/ https://www.reddit.com/r/Python/ . In particular, I've heard good things about "Automate the Boring Stuff with Python".
- dtornabene 10y agoIts a great book, that still has relevance, amazingly. Theres also the fact that he feels like its necessary to shit on anyone who disagrees with him...or, anyone at all actually. The trolling thing is lame, and a total waste of peoples time, like, for example, when he literally ate something in the middle of his lecture at Pycon, as if he somehow couldn't find the time to eat a candy bar in the elevator. I literally worked Pycon, and I can guarantee you that speakers, and pretty much anyone else, can find the two minutes to choke down an orange or whatever before the go up to speak. Its his persona, which he uses to get notoriety, which he uses to get work.
- crispytx 10y agoLearn Python The Hard Way was the first programming book I ever read. Beats the hell out of codeacademy and all that other shit.
- nof 10y agoI would basically avoid this simply by reading his idea of what makes good educational content: tests, repetition, memorization and boring predetermined projects. If you know anything about educational theory, you will quickly discover that constructivist education, or constructionism as Seymour Papert coined, is a way more effective and motivational way to learn computer science and coding. There are basic understandings of computering which is beyond specific language, eg loops or logic. You are not doing yourself any favors by memorizing the entire syntax of a language. This happens while you do personal and engaging coding projects.
- oli5679 10y agoDoes anyone have any advice from where to go after beginner/intermediate python? I can hack together a program with the functionality I want, but frequently it's pretty verbose and the architecture gets creaky as the complexity increases...
- yhoiseth 10y agoI'd suggest http://www.obeythetestinggoat.com/ http://www.obeythetestinggoat.com/ if you're looking to use Python for web development.
- pnt12 10y agohttps://learnpythonthehardway.org/book/nopython3.html https://learnpythonthehardway.org/book/nopython3.html >This document serves as a collection of reasons why beginners should avoid Python 3 as of November 22nd, 2016. This is the first thing I get when searching "Learn python3 hard way" in Google. Maybe it's time to update this page :) I didn't enjoy the python2 book too much, but I'll give this one a try.