Show HN: Learn Python the Right Way – free introduction to Python book
learnpythontherightway.com
learnpythontherightway.com
I have nothing to do with the authors of this book/page but this attitude is why I don't do free software.
One, a Gmail that I’ve had forever, is my “public” email that’s just filled with junk.
The other is used for stuff like banks, utilities, etc. and I protect it fiercely from spam of any kind.
It’s easy to know what to pay attention to that way and made my life more enjoyable, or at least easier to parse.
For services and what not I know and trust I go with a regular alias with my domain for this purpose. And I have service specific aliases such as foo@example,com so I can delete the alias if necessary which is rare.
Then there the quick thing that you can do with any address for separation of concerns with foo+bar@example.com so if your email address is foo@example.com, just make a quick and dirty instant alias by signing up with, say, foo+bar@gmail.com.
What attitude? The selflessness of the developer for giving away the software, or the gratefulness of the user who got exactly what they wanted? In either case, I struggle to see what repels you.
I give away my recent eBooks for free (and also provide a link where people can pay if they want). Because I am an author, I have met many interesting people and have had job opportunities appear without my having to search for them. Also, I love the process of writing. BTW, I started out writing for conventional publishers (10 books) and transitioned to this Creative Common self publishing approach.
The same comment may apply to my open source projects - not sure.
My irremediable descent into nerddom started when I got a cheap netbook. It was an awful machine, but I could freely poke around and learn stuff.
If you're just starting, a potato computer that you fully, exclusively own is much better than a great machine that you share with other people.
But of course it's a big time investment and not everyone is interested. If you just want to learn the basics of programming, a fully managed environment is also fine. So much is being abstracted by the programming language itself that the underlying stack is almost a detail.
I've taught a lot of Python and I think this book (adapted from How to Think Like a Computer Scientist") is the best mix of practice and theory and is usually what I recommend to people as a 'fixed syllabus' when they are overwhelmed by all the options.
I've added that code snippet in now. Feel free to let me know if you spot anything else :)
The site also links to the original which is more battle-tested at this point [0]
[0] http://www.openbookproject.net/thinkcs/python/english3e/
wn.title("Hello, Tess!")
This fails in Repl.it's turtle repl environment.
Not sure why, but this feels very backwards to me.
I mean, I get it. E.g. Overleaf is a much gentler introduction to LaTeX than Miktex/texlive ... but still. Feels like you're crippling the student in advance by limiting their ability for exploration/exploitation.
Of course this is a blessing of Python but an obstacle for teaching a language to beginners, if you're spending a lot of time troubleshooting installations and wondering why a program runs on one computer and not another. It may explain the staying power of Matlab, which all comes from one place and installs the same on everybody's machine.
From talking to people who have learned programming recently, almost every course starts with walking the student through a specific, prescribed installation and making sure it works.
It suggests a possible opportunity for another book along the lines of: How to install Python, which explains a variety of scenarios, what they are for, how they work, etc.
One benefit of a web based IDE is that it works for K-12 students who are on Chromebooks and can't install software. When my son brought home his school issued Chromebook, my first response was: "Great, let's install Python." He gave me a sad look.
Which student has learned more about Python?
Which student is better equipped to pursue setting up an environment (maybe on another computer) at some point in the future?
Setting up environments is the most frustrating, seemingly pointless task ever to an absolute beginner. Someone who has literally never written a line of code in their life and has 0 experience troubleshooting anything is extremely likely to get 1 step wrong, or worse have one precondition wrong on their machine that breaks the tutorial's steps, and then get stuck in an endless sea of non-functioning, useless applications now stuck on their hard drive & then become completely disillusioned & never start coding.
The lack of setup on the student's part is why previously I have always recommended FreeCodeCamp as the single best way to learn programming on the internet to an absolute beginner, but now that this exists with its replit-based approach (and I know about it) I'm gonna take a look at it and potentially start recommending it instead.
P.S. how many IDE shortcut keys did you have to customize before you were at all comfortable with using them? And this is Python, so if we're sending them to VSC instead of Pycharm, imo we're doing them a huge disservice*, and Pycharm's default keybinds are particularly egregiously beginner-unfriendly.
*IDE wars aside, arguably the real disservice is locking them into one before they have enough knowledge to form their own opinion
I hear this a lot, and maybe I'm just too far removed from a total beginner's perspective to understand, but what exactly is complicated about installing Python?
Windows in particular is as simple as it gets - there's a Windows Store App that you can install and that's pretty much it.
Call me old-school, but I consider being able to install and start a program on the system I use on a daily basis an essential skill and a pre-requisite to programming. If (and that's one hell of an "if" these days) something goes wrong and troubleshooting is required, the necessary "skills" (read: google the exact error message, maybe followed by some process of elimination) overlap with the skills needed during programming so it actually helps, too.
It rubs me all the wrong ways to tell students to sign up with a commercial online service for something they can experience for free, offline, and without surrendering personal data to some corporate entity on the internet.
As far as IDEs and shortcuts go, that's another thing I just can't wrap my head around: so there are people who are apparently incapable of double-clicking an icon in their respective OS's package manager/app store, but at the same time they are expected to care about particular key bindings and shortcut keys?
I just don't understand this at all. Not to sound like your typical geezer, but back in the day a blinking cursor and a magazine explaining the most important BASIC commands was all you needed to get started. Shortcut keys are the last thing beginners should worry about.
Heck, it's perfectly fine to stay on the REPL for a while and just use a simple text editor for bigger scripts. Even syntax-highlighting can be enabled via plugin in most text editors that are even just better than Notepad.exe.
But again, maybe I'm just way to detached from your typical absolute beginner to even remotely understand any of these issues.
Ok I haven't installed Python myself this way, but, does it set up PATH for you properly? How about pip, does it add pip to PATH? Often things will tell you to type `pip install` rather than `python -m pip install` so there's a potential source of confusion pretty early on too.
(Currently, I tell people to install chocolatey then use that to install Python because choco does take care of PATH for both Python & pip. If Windows app store Python install takes care of all of this maybe I'll try suggesting this next time and see how it goes.)
Also, let's suppose you get Python from Windows app store. Great, you have installed Python 3.9! You are doing the tutorial, just lovely, now in a week you want to make a Discord bot! Great first project. Uh oh, RED Discord Bot requires Python 3.8 (3.9 introduces breaking changes for some of its dependencies). How much more trouble you are now in because you have to install two versions of Python at the same time! If only you had waited to install any version until you were ready to start your first local project. (Based on actual events)
As far as IDEs go, well, in Pycharm you are asked, do you want to set up a project? Huh? What's a project? (Later on: well, you can't just open a file from Windows Explorer, you need to open your entire project! Well, isn't THAT confusing!) Then you have to answer about a venv. What's a venv? Oh, shit, I made the folder in the wrong place, let me move it, omg, nothing works anymore, oh, I guess that "venv" thing was kinda important to know about after all, well, shit...Ok, so again, maybe don't jump all the way to Pycharm as your first IDE but then I just have to ask why are you using an IDE at all when replit would do just fine? Then you're going to have loyalty to a tool that's worse than Pycharm and not want to switch once you are ready to use the right tool.
> But again, maybe I'm just way to detached from your typical absolute beginner to even remotely understand any of these issues.
I think this is pretty likely; if you haven't helped a friend start from literal scratch in the past year, it's pretty hard to realize just how confused people can be. And a LOT of people have tried things before and given up in frustration because they remembered how painful the setup was. So that leaves them with messes on their computers and also psychological scars of "oh my god not another setup, please not another setup, don't make me do another setup...."
Plus, if you have always had someone to ask for help then it's hard to appreciate just how painful setups can be when you're stuck on your own for them. If something breaks, no one's going to fix it for you, it's just broken, and you're just alone, and you feel REALLY goddamn stupid because as your comment points out, setups seem like they ought to be trivial. But they really just never are.
If you need to have multiple versions installed then presumably you are sophisticated enough to manage the PATHs for those versions/projects.
Setup is a pain, I get it. I try to avoid it if it isn't necessary for the courses I'm teaching.
> it's pretty hard to realize just how confused people can be.
It's good, though! Confusion is a sign that someone is confronting something they don't understand, which is an opportunity to teach them about what they're doing, or at least motivate them to understand it a little better.
I sympathize with people who want to promote a browser-based, sandboxed coding experience- I really do. Teaching people to code on it is a whole different story. Imagine what would happen if we raised a generation of Python scriptwriters who couldn't figure out how to install to PATH, or taught C without showing people the compiler. There's no excuse for not knowing how to operate your tools, and learning them first is an absolute must. You don't let someone start playing with a rotary saw until they know how to use it.
Once they’re all in they’ll pull an all nighter if necessary to get something done.
Things like Repls often turned me off if they left me feeling like the things I was running in them were contrived and ephemeral.
Even if I was producing some cool graphic or something, there was always this nagging feeling that I wasn’t making something “real” that could be saved off and shared. Almost like the difference between messing around with a dry erase board vs learning how to draw with a pencil and a sketch pad.
But at the same time, PHP was instrumental to my learning how the web worked, in part because of how easy it was to find shared hosting that easily mapped PHP files to web routes 1:1. I can’t imagine I would have learned much if my first step was installing Apache, then mod PHP, then mod rewrite, then setting up htaccess files and directory permissions and then realizing that I didn’t get the PHP with GD graphics installed.
Maybe this is an “everyone learns differently” thing, or maybe this is a “the right answer is somewhere in the middle” thing.
The gap that needs to be minimized, I believe, is the gap between deciding to start and being able to produce actual usable stuff.
So, for example, the use of shared hosting that mapped PHP to web routes meant that you could get started and immediately create actual websites on the internet. Having to do that manually via setting up Apache, etc., makes that gap significantly larger.
OTOH, an online REPL lets you see the results of your code, but doesn’t actually let you create actual programs that you could use. Whereas setting up a local environment means that you can immediately create Python scripts that you can actually use.
An online REPL, in this way, only adds to the gap between someone deciding to start and creating real usable outputs.
Ok, now you've lost me completely. I am at a total loss as to what you're even trying to argue here.
When I look at the installation instructions for RED Discord Bot on Windows [0], I'm greeted with this:
> We require installing Red into a virtual environment. Don’t be scared, it’s very straightforward.
So even your Bot library (aside from a bazillion dependencies [chocolaty, JRE 11, Git, build tools, ...]) recommends using a virtual environment.
At that point installing a different Python version is the least challenging part of the endeavour.
So either I my mind works in very twisted ways, or your example was exceptionally poorly chosen.
[0] https://docs.discord.red/en/stable/install_windows.html#crea...
It is not the best environment, but it (generally ) works in Mac/Linux/Win, and it allows them to work on their own computer. This sidesteps environments, but also doesn't make them dependent on having the internet or other services.
On the flipside I teach an analytics class for my alma mater and there we use Colab. Again, sidestepping install completely. I justify it as these folks are more interested in leveraging the tools of Python (matplotlib, sklearn, pandas) and don't necessarily want to be software engineers. For the motivated few who want to install locally I give them a guide [0].
The point, to me at least, seems to be laying the groundwork for even more learning and experimentation in python, while making it as easy as possible to do so.
It also has the benefit that any reader will end up with the same expected environment the guide is written for.
I will say that I totally agree that calling it the "right way" is disingenuous at best, and pure marketing fluff at worst.
Edit: I guess this would constitute as more of a tutorial of insert IDE here. But even picking one like VS Code would go some distance toward learning the full scope.
In the long run I'm afraid books are not a good format for helping with this. Too many individual differences, and too many things change over time.
Since I lost my link to this I actually stumbled upon this as well -- evidently UMN has a library of open text books:
Here's a link in the meantime if you need
https://i.ritzastatic.com/learn-python-the-right-way/learn-p...
I can't speak to the Python book, but his Unix and SQL books are fantastic.
Telling beginners as late as 2017 that "python3 is such a failure it will kill python".
That's not controversial, that's just wrong, especially but not only in hindsight.
What a burn.
And I would argue that concurrency, at least, has no business in a textbook for true beginners.
Why on earth not? Lots of people begin by wanting to program a simple real time game and concurrency of some kind is absolutely required to do that.
Concurrency not being a first class feature of most mainstream programming languages and frameworks and being clunky in most of the rest is one of the biggest failures of language design in my opinion.
And lots of people program Arduinos and similar kit as their first attempt at coding now, are you going to tell them not to use concurrency?
It does not have the strong type guarantees of the ML or Haskell families; functional code in Python is fragile and complex.
Python lambdas, like those in virtually all functional languages, are a single expression.
Python expressions are somewhat limited (at least if one avoids non-idiomatic, and often somewhat ugly constructs) because Python isn’t a purely expression-oriented language, and the Pythonic way to do certain things involves statements. [0]
> no tail call elimination
True, then again, TCO has a clarity cost and lots of lisp family languages have either no TCO or self-call-only TCO, or kinda-self-call-only-TCO-via-explicit-recursion-constructs.
Python is metaprogrammable enough that you can do TCO via decorators (a couple of ways; I’ve seen mutual [1] and self-call-only done via stack frame manipulation decorators, and self-call only done even more efficiently via a bytecode injection decorator.)
> and hardly and FP in the standard library.
Not sure if you mean hardly any use of of support for; if the latter, it is simply wrong, if the former, I haven’t read much of the stdlib source code but who cares?
> It does not have the strong type guarantees of the ML or Haskell families
Which in turn don’t have the metaprogramming capacities of the Smalltalk-descended line of dynamic OO languages. Its not ignoring things to make choices that have tradeoffs.
[0] but note that this is mostly about idiomatic, not functional limitations, there is very little if anything that idiomatically uses multiple statements in python that can’t be done in a single expression using only language-level expression elements plus built-in and stdlib functions
[1] that is, general but all participating functions must be decorated.
It progressively deemphasized some popular FP patterns (largely in favor of comprehensions, which have also been adopted in many newer functional languages.)
We're trying to avoid programming language flamewars here, among other kinds of flamewar.