[HN Gopher] Ask HN: Which book would you recommend for learning ...
___________________________________________________________________
Ask HN: Which book would you recommend for learning Python in
detail?
Hi, I know some programming. I know C and some python as well. I
have built projects with python but every time I work with python,
I feel like python is made on the simple basic structure and I
don't know that. I find myself constantly looking for small things
as well, I feel like I really don't know the internals of pythons.
Which book would you recommend that you go beyond the syntax and
shows how things works on a basic level so that I can get build up
some intuition while working with python. Forgive me if I failed to
express myself.
Author : jacoberr
Score : 131 points
Date : 2023-01-29 16:14 UTC (6 hours ago)
| moveax wrote:
| https://futurecoder.io
|
| It's not a book, but I loved it and it is really helpful.
| faizshah wrote:
| I was the same way I always felt like I was writing Java in
| Python, I was able to make useful scripts in Python but I wasn't
| able to actually "code" python. Then I took a class on python and
| finally everything just clicked (I studied some other books
| during the class as well).
|
| For learning python (if you already know some programming) I
| always recommend "Introudcing Python" by Lubanovic it gives a
| coverage of all the major python features.
|
| Once you are able to code basic python I use the book "Fluent
| Python" by Ramalho (I still use it to this day even as an
| advanced python programmer). This book has an amazing coverage of
| every single advanced feature in python. Anytime you're on the
| job and you know you could use some fancy classes or some async
| stuff or maybe multi threading you can visit a chapter in this
| book and get up to speed on it. I probably open this book once a
| month just to refresh my knowledge on some particular python
| feature I want to use.
| AdmiralAsshat wrote:
| I used Learn Python The Hard Way[0], given that I had gone
| through the author's Learn C the Hard Way previously, but I
| gather that Mr. Shaw is something of a controversial choice.
|
| [0] https://www.amazon.com/Learn-Python-Hard-Way-
| Introduction/dp...
| drexlspivey wrote:
| This guy is one of the reasons that held back Python 3
| adoption. I remember starting with his tutorials around 2017
| which were adamant that begginers should not learn Python 3
| while at the time his course was the hottest one and was
| massively promoted on reddit for example. He was also
| publishing articles like this [0].
|
| It's great that people like him are spending a lot of time
| helping others learn but imo he has done more harm than good.
|
| [0] https://learnpythonthehardway.org/book/nopython3.html
| AdmiralAsshat wrote:
| > This guy is one of the reasons that held back Python 3
| adoption.
|
| That seems like an extraordinary amount of influence to
| ascribe to one guy who wrote a textbook. Python 3 adoption
| was mostly driven by large projects. I can't think of any
| sizable Python project that would base their decision to
| migrate on what some introductory CS students are learning.
| noufalibrahim wrote:
| I second this. The exercise style has been effective and i use
| this as a textbook for all the students i coach.
| saboot wrote:
| It's from 2015, but I learned a lot from watching Philip Guo's
| playlist on python internals
|
| https://www.youtube.com/playlist?list=PLV7iu6GiDKwQWZbapY5mP...
|
| Like you I want to know more about CPython behind the scenes, not
| how to use Python itself. I like the deeper understanding
| serjester wrote:
| While I'd likely recommend a book over YouTube playlists, I
| also got a lot of value from the YouTube channel of the guy
| that wrote pre-commit (anthonywritescode). He does everything
| from explaining the basics all the way up to debugging Cpython
| internals. It's a great find since the majority of coding
| channels tend to be beginner focused.
| spudlyo wrote:
| I also enjoyed watching Anthony's videos, a lot of them are
| short and focused on a specific subject. I stumbled upon his
| channel when I was struggling with some challenging type
| hinting issues, and ended up binge watching hours of his
| content.
| tmh88j wrote:
| +1 for Anthony's content. He even has a repository on github
| [1] with links to all of his videos for easier searching, and
| they're all labeled with a difficulty level. It's currently
| up to 520 videos!
|
| [1] https://github.com/anthonywritescode/explains
| [deleted]
| f311a wrote:
| If you want to go really deep, I would recommend reading some
| blogs about Python internals:
|
| https://tenthousandmeters.com/tag/cpython/
|
| https://rushter.com/blog/tags/cpython/
|
| https://eli.thegreenplace.net/tag/python-internals
|
| https://realpython.com/cpython-source-code-guide/
|
| I'm not aware of any good books about Python's internals.
| xavdid wrote:
| On the one hand, it's great to know what's happening (deep)
| under the hood and this probably makes for very interesting
| reading.
|
| On the other hand, if you want to be a productive Python
| programmer, don't feel like you need to know anything about C++
| to do so. there may eventually come a time where it becomes
| relevant for you, but you can get _very_ far before it comes
| up.
| DataDaoDe wrote:
| great stuff, thanks so much! ! I've been looking for python
| internals resources.
| pdhborges wrote:
| There is one book about the CPython internals:
| https://realpython.com/products/cpython-internals-book/.
|
| You can also explore the CPython dev guides:
| https://devguide.python.org/internals/.
| __rito__ wrote:
| _Python Crash Course_ by Eric Matthes.
|
| I am a Deep Learning Research Engineer who works 100% in Python.
|
| I had just started second year in college with only basic
| knowledge in imperative C. Didn't even know how to write a C
| function other than main().
|
| Then I started learning Python with _Python Crash Course_ by Eric
| Matthes.
|
| I finished the entire book in five days. I really enjoyed it and
| learned a lot.
|
| This is the ONLY programming book I read cover-to-cover, and the
| only Python book I have ever read.
|
| This book served me greatly.
|
| When anyone asks for Python book recommendation, I recommend
| _this book only_.
|
| You don't need any other.
|
| This book has the basics taught, then goes through three
| projects. One of them is a game. I remember.
|
| All the exercises are great, self-contained, doable without
| outside help, and help you grow.
|
| And the book's design has all that No Starch Press goodness to
| it.
|
| Go for it.
| clumsysmurf wrote:
| Its easy to miss, but the Third Edition just came out Jan 2023.
| gjvc wrote:
| Where did you learn to write in this style?
| __rito__ wrote:
| Is it any good?
|
| It mainly started in Humanities classes in middle school. I
| had great History/Geography/Bengali teachers there.
|
| The gist of what they taught me was to optimize writing for
| one thing and one thing only- clear communication of
| information. No need to impress or bloat. So that the person
| grading your test copy finds it the most convenient to read
| your answer (hence bullet points, smaller paragraphs, etc.),
| and finds the answer so easily, that they don't dare to
| deduct marks. India is big on standardized tests, and a total
| stranger grades your copy.
|
| I used to optimize for grades, and now I do for communication
| of information. I employ the same things when writing
| tutorials, documentations, and reports.
|
| I am a reader, and some advices from one/two memoirs of
| authors I read stuck with me.
|
| I also used to spend 10-20 hours per week on Quora during
| college, and was in the eyes of admins there, and worked on
| all sorts of pilot projects. I also had real recognition and
| multiple thousand followers in one non-English language
| version of Quora. Practice comes handy.
|
| I also think communication is very important- in teaching,
| presenting, and writing. So writing is only a part of a
| bigger part of myself. And communication not in the smelly
| MBA/LinkedIn kind of way. Communication in its true sense.
|
| I also think that I shouldn't try to impress or flex while
| writing. I can comfortably do that because I have plenty
| other ways to wow people in life. So no word or sentence I
| use is engineered to impress anyone.
|
| And I always keep in mind that I am selling something. (I
| have no ties to the publisher or the author of the book here)
| I really benefited from the book, so I spread the word
| whenever I can. So, if I can convice 10 people to buy/borrow,
| and 2 of them read it in full, I honestly believe that they
| will benefit.
|
| I don't think I am a particularly good writer. However, if
| you find it good, this is how I do it.
| ergonaught wrote:
| Looks like Facebook advertising meets Ultima Online chat.
| lordgrenville wrote:
| LinkedIn would be my guess...
| __rito__ wrote:
| I went through and still go through many other Python resources
| like blogs, videos, etc. But never another book or any MOOC on
| Python.
|
| And reading and working with large codebases is very important
| for practical work. And it has no substitution.
|
| I will recommend this path:
|
| Read and do all exercises from Python Crash Course ---> Solve
| coding problems from Codewars. Choose Codeforces or Project
| Euler as well, if you have the corresponding bend ---> Make
| your own projects, solve your own problems ---> Contribute to
| Open Source projects --> Get hired. Unique growth happens after
| using a language in job. Or use Python in your job
|
| In the intermediate space somewhere, learn something where you
| can _use_ Python. It may be webdev, gamedev, cybersecurity, or
| ML /AI. _Using Python_ is the key here.
|
| Different people want different things when they want to learn
| a language. So, choose based on your goals.
| dfee wrote:
| Is learning a language by book effective? Despite my efforts over
| the last ~25y, the only way I've learned is actually building
| crap software, and tuning it with learnings from language-
| specific frameworks and API docs.
|
| The books just collect dust - and yet, every few years I try this
| experiment again with the same result.
|
| Kinda interesting aside: I've been told I write _great_ code in a
| particular language, while eschewing near universal patterns -
| patterns I'd probably have picked up if I'd gotten to Chapter 3
| of any of these books. (It's hard to independently discover cargo
| cult habits).
|
| My take on the question: no book necessary.
| wrigby wrote:
| I learned to program in my early teen years from books I
| checked out from the library, but since then didn't read a
| single programming book.
|
| Recently, I needed to ramp up quickly on an embedded C project
| (without any past MCU programming experience), and turned to a
| book for the first time in ~15 years. It was a refreshing
| experience - it was a short book, and I read it cover to cover
| over a weekend, but it really enabled me to be successful in
| the project I had to take on.
|
| I like to think of real-world experience as building a sponge:
| you fill in the areas that you need to as you go, creating a
| sparse structure of knowledge. This complements formal training
| (whether a book or a class) - I think of these more "complete"
| approaches as pouring water into the sponge. Having hands-on
| experience lets you take more advantage of a class or book, and
| the class or book fills in the gaps that you simply didn't have
| to learn as you built things.
| rhizome31 wrote:
| I guess it depends on people. Books have been very useful
| companions for me over two decades. They help clarify and fill
| gaps in my knowledge. Hands-on experience comes first but books
| are a useful addition.
| spudlyo wrote:
| For some people, I assume it's effective, it's never been that
| way for me. I learned Python by writing Python code and reading
| the official Python docs and supplementing those docs with
| random blog posts and other Python sites. Folks who don't
| already have a number of programming languages under their belt
| may benefit more from a book perhaps.
| [deleted]
| guiambros wrote:
| Fluent Python [1] is a great book, very comprehensive, yet it
| goes deeper than just the basics. Python Distilled [2] is another
| option. Or if you prefer more project-oriented learning style,
| Automate the Boring Stuff with Python [3] is probably a better
| fit.
|
| When you're ready to go beyond the basics, I recommend Effective
| Python [4] and Serious Python [5]. Both go deeper on classes,
| metaclasses, how objects are represented internally, and Serious
| Python covers a bit of functional programming, scaling, etc.
|
| [1] https://www.fluentpython.com/
|
| [2] http://www.dabeaz.com/python-distilled/
|
| [3] https://automatetheboringstuff.com/
|
| [4] https://effectivepython.com/
|
| [5] https://nostarch.com/seriouspython
| faizshah wrote:
| Fluent python is great but I don't recommend you start with
| Fluent Python, it's for people who already know python and want
| to go that extra mile. I still use it as a reference almost
| every month.
|
| Automate the boring stuff is a good beginner book, I like the
| coverage in "Introducing Python" by Lubanovic because it covers
| Modules and Packages for a whole chapter whereas in other books
| distributing your code is often a footnote. Even Fluent Python
| (my favorite python book) doesn't have that great coverage of
| that.
| wefarrell wrote:
| Personally I found Fluent Python to be one of the best books
| I've read for learning a new programming language. I had
| slight Python familiarity before and over ten years of
| professional experience writing code. I was coming into a new
| job as an engineering manager managing a team of experienced
| Python developers and had to get up to speed very quickly so
| I spent a few weeks doing the Python track in Exercism while
| simultaneously reading Fluent Python and I was able to get to
| the point where I felt confident reviewing my reports' code
| and giving worthwhile feedback.
| emmelaich wrote:
| If you consider yourself a good programmer, read the official
| reference documentation. A good book was Essential Reference by
| Beazley but I don't think it was updated for Python3 yet.
| [edit: http://www.dabeaz.com/python-distilled/ _is_ the Python3
| version]
|
| Also perhaps Python Cookbook.
|
| A major part of any language is knowing the standard
| library(-ies).
| Jeff_Brown wrote:
| I would recommend not learning any language completely or for
| it's own sake. Learn what you need when you need it. Most popular
| languages are absurdly sprawling things, designed to cover far
| more conditions and often to suit a far bigger variety of tastes
| than any single person needs.
| rapfaria wrote:
| OP thinks her education is lacking, and wants to deep dive in a
| language she already uses.
| rmk wrote:
| I have a recommendation that goes against 'learn the language
| constructs by reading a book about them'. I recommend Python
| Module of The Week.
|
| https://pymotw.com/3
|
| The advantage of this is that you learn by looking at examples,
| and at the same time you learn the standard library. In my
| opinion it's much more valuable to learn the standard library of
| a language once you know a little bit of the language itself,
| because it helps you write useful programs and learn the language
| in that way.
| Hermann12 wrote:
| Hi, I learned FORTRAN on University. After that I don't
| programming, but as an engineer I searched some solutions for
| automatisation. So I have to learned programming again, because
| FORTRAN can't solve my requirement.
|
| Python Crash Course, 2nd Edition: A Hands-On, Project-Based
| Introduction to Programming, by Eric Matthes is my favourite for
| self study the basics.
| Hermann12 wrote:
| Link: https://ehmatthes.github.io/pcc_2e/regular_index/
| sitkack wrote:
| Welcome to HN Hermann12.
| bloopernova wrote:
| I highly recommend you don't use a book, and instead use
| www.exercism.org instead.
|
| Its lessons are free, open source, and extremely accessible. Nice
| and short, too.
|
| And, once you're proficient, you can contribute back to it!
| lancepioch wrote:
| https://docs.python.org
| pottertheotter wrote:
| Surprised no one else mentioned this. The official
| documentation includes a tutorial that is quite good. I would
| read it before jumping into Fluent Python.
| https://docs.python.org/3/tutorial/index.html In addition, you
| can download the docs as a PDF. Several years ago, I printed
| the tutorial so I could sit on the couch and read through it,
| which was a much better situation than having to do it on a
| screen of any type. https://docs.python.org/3/download.html I
| really wish all docs would have a PDF option.
| __mharrison__ wrote:
| I wrote Illustrated Guide to Python 3 to fill in knowledge gaps
| that I kept coming across while training folks.
|
| It is so easy to go to SO and copy and paste code and not know
| what is really going on. I think understanding Python at a deeper
| level will be even more important now that chatGPT will spit out
| the code for you and happily lie about some things.
| sitkack wrote:
| http://www.dabeaz.com/python-distilled/
|
| I would recommend compiling a debug build of Python and stepping
| through it while it executes your script, even if it takes you an
| entire day for a simple script. Python is a big dictionary
| sandwich. Everything is a dictionary, even dictionaries.
|
| What does
|
| A.b.c() do?
|
| You do not need to _know_ the Python internals. The semantics are
| good enough, but the leak through everywhere. You might enjoy
| using https://micropython.org/ to learn instead.
| pca2 wrote:
| It's not a book, but the Python3 Deep Dive courses by Fred
| Baptiste on Udemy are very good at helping to understand the
| internals of python: https://www.udemy.com/user/fredbaptiste/ If
| the courses are pricey, remember that Udemy seems to have major
| sales every couple of weeks, so I'm sure they will come down in
| price again soon.
| jphoward wrote:
| James Powell frequently gives very deep Python talks at
| conferences like Pydata, and shows you his coding approach in
| real time on Vim. Plenty of them are on YouTube and are worth a
| watch. This one [1] entitled "So you want to be a Python expert?"
| has almost half a million views!
|
| [1]
| https://www.youtube.com/watch?v=cKPlPJyQrt4&ab_channel=PyDat...
| giancarlostoro wrote:
| One free resource I recommend is reading PEP-8 which is a Python
| style guide. It gives you standards to follow when coding which
| makes it easier to go back to code as you get used to it. Editors
| like PyCharm Community / Pro support it out of the box, on VS
| Code you need to install a plugin, but once you do, you're
| golden.
|
| I also recommend reading the official Python documentation,
| especially when working on things, and looking at functions
| within whatever module you are using that you are not using. Over
| time you will discover functions / methods you had no idea were
| in there. I also suggest just exploring other modules you have
| yet to use.
| CraigJPerry wrote:
| I wouldn't recommend a book, instead i'd give you a couple of
| challenges, each of these is <1-2 hours in isolation:
| 1. Explain to me like i'm 5, what exactly __slots__ is for?
| Write me some demo code to illustrate - the reason i'd set this
| challenge is because you'd come out the other side knowing how
| objects work and how it's more or less dicts all the way down (to
| be clear, slots is an exception to the dicts all the way down
| view which is why i think its a good example to get stuck into)
| 2. Write me some demo code that explains the purpose of locals()
| 3. Teach me how to use dis.dis(), explain to me what each
| possible opcode means 4. Explain to me how to use pdb,
| include conveniences like breakpoint() in your explanation
| 5. Show me 3x working examples of calling a c function from
| python. Explain the different approaches you took
|
| If you can nail these 5 questions, I'd feel pretty confident
| betting on you knowing enough python to be able to take on
| something really advanced like modifying the supported grammar of
| jinja for example.
| emmelaich wrote:
| These seem to be too deep in the internals for most Python
| programmers.
|
| OK, __slots__ and pdb, but the rest are "as needed" and don't
| have much to do with everyday Python programming.
| bckr wrote:
| * Effective Python
|
| This teaches 90 specific ways to be more Pythonic
|
| * Robust Python
|
| This teaches some architectural / implementation patterns for
| code bases larger than a script
|
| * High Performance Python
|
| How to get the most juice out of Python, including compiling
| aryanAr0ra wrote:
| https://learncodethehardway.org/more-python-book/ You cannot go
| wrong with this. Get ready to implement Unix commands like cat,
| find, grep, and many more. This book will guide you to make a
| basic shell, a BASIC Interpreter, vi text editor, a command line
| browser and many more projects.
___________________________________________________________________
(page generated 2023-01-29 23:02 UTC)