6 ms·
Show HN: I wrote a book about Python
- dmuller 5y agoHi everyone, Last year, I was lucky enough to sign a book deal with The Pragmatic Bookshelf to write an intermediate level book on Python. (The Pragmatic Bookshelf is the publishing company founded by the authors of one of my favorite programming books: The Pragmatic Programmer.) Having written Python most of my professional career, I wanted a resource that I could give to engineers who might have deeper experience in some language that wasn't necessarily Python. I wanted to help teammates newer to Python quickly discover its virtues (and limitations). I think there are tremendous Python resources available online, but wanted to capture another perspective to help teammates level up their skills. The book ("Intuitive Python: Productive Development for Projects that Last") went through a beta release this spring, and was officially released this month. It's available (including a few free sections) here: https://pragprog.com/titles/dmpython/intuitive-python/ https://pragprog.com/titles/dmpython/intuitive-python/ In case anyone is thinking of becoming an author with the The Pragmatic Bookshelf, I'd be happy to share my thoughts about the publishing experience there (spoiler: I had a positive experience). I'm proud to have released this book, and excited to share it here. Thanks! -David
- mraza007 5y agoHey man just wanted to say congratulations on publishing this book. As I python developer myself do you think I can use this book to further advance my knowledge of python
- dmuller 5y agoHey - thanks I appreciate it. I'd take a look at the table of contents and see if any of the topics look familiar/unfamiliar to you. The preface excerpt (http://media.pragprog.com/titles/dmpython/preface.pdf http://media.pragprog.com/titles/dmpython/preface.pdf) also has a bit more detail about what's in each of the chapters. The book's content is probably most useful for someone newer to Python, but I still think there might be value in it depending your background
- mraza007 5y agoYup I definitely agree with you and hey thanks for replying
- albatross13 5y agoI'd like to give my congrats as well, writing a book is no easy feat. That's awesome and congratulations!
- okareaman 5y agoCongratulations on your book! I am fortunate enough to know quite a few languages, so I decided to pick one for all my needs and it seemed Python fit them. Then I recently read on HN "Why Python is not the Language of the Future" https://news.ycombinator.com/item?id=27562931 https://news.ycombinator.com/item?id=27562931 The arguments put forth seemed weak, but wondered what you thought
- dmuller 5y agoI think Python definitely has its drawbacks, and it's not fast. The other downsides listed in that article (whitespace, variable scoping, lambdas, mobile, etc.) may also be get in your way sometimes, but seems doubtful that they are language killers...I agree the argument presented in that article is weak. I'm biased, but I think Python as your daily driver language is a great choice.
- okareaman 5y agoThanks. If I need speed I can always interface to C. I'm still going to learn a bit of Julia today to see what it's about.
- nerdponx 5y agoPyPy and GraalPython also can offer significant speedups in certain workloads.
- gota 5y agoPreamble: I like Python - it seems to fit my mental models well, and I'm productive writing in it. However, only just recently I tried to develop a more-than-trivial program to deploy as an executable for my Windows-using friends. This may sound naive, but I'd never thought about how hard it is, especially when mostly everything else in Python is well-tooled, well-documented, and works. If you check my post history you'll see I've been following this subject lately... in the hopes I won't have to re-write my stuff in C# or something. I got it done, but am thoroughly underwhelmed by the experience and the resulting size of the executable (due to cascading dependencies that I'd really rather not pick apart). So here's the question - what's your take on how to package a Python program as an executable (wherein package does not mean Python package, but generate a click-and-run Windows executable)? Anything on that in the book? I can't tell from the 'Contents' list, but it seems not, right? Congrats on the book. I'll take some time to go over the Extracts (and thanks for those, too!)
- criddell 5y agoWhen you need a GUI on your Python program, what do you use?
- manjana 5y agoTkinter is a choice.
- TruthWillHurt 5y agoThis was recently on HN, seems interesting (didn't try it yet though) https://github.com/chriskiehl/Gooey https://github.com/chriskiehl/Gooey
- sateesh 5y agoCheck PyQt which provides python bindings for Qt.
- zerr 5y agowxPython is great. wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard Python GUI toolkit is that Tkinter was there first. -- Guido van Rossum
- oumua_don17 5y agoThe official python bindings for Qt ie pyside [1] [1] https://www.qt.io/qt-for-python https://www.qt.io/qt-for-python
- d0mine 5y agoOn "Calling Other Programs with subprocess": It pains me that the default way to run an external command (subprocess.run) doesn't raise an exception for non-zero exit code violating the Zen of Python: "Errors should never pass silently. Unless explicitly silenced." Would it make it too advanced to show subprocess.Popen example with stdin=PIPE for providing input instead of writing to disk? Or an example on how to force timeout for a command that might spawn its own child processes (send signal to a process group).
- jnwatson 5y agoJust pass check=True as an argument to subprocess.run and it will raise a CalledProcessError.
- d0mine 5y agoThe issue is that `check=False` by default for the `run()` function.
- dmuller 5y agoYeah - I agree, I don't like the default behavior of subprocess.run either. As another commenter pointed out, passing the check=True argument makes subprocess.run raise an Exception if the underlying command doesn't return 0 (would have been nice if this was the default). Those are two good use cases (using the lower level subprocess.Popen + process group signaling) that the book does not cover---thanks for bringing them up.
- auxym 5y agoNonzero exit as an error is only a convention, no? I've definitely used CLI programs in the past that used nonzero codes to report all sorts of non-error statuses.
- dijit 5y agoIt's more than convention though. if you run those commands in bash with `set -e` then the script will exit early when a command exits non-zero. I often run: `set -euo noglob -o pipefail` which is a way of preventing cascading catastrophes with bash scripts.
- mkl95 5y agoCongratulations! Maintanability and tooling are underrated topics.
- usrme 5y agoSeeing as your title managed to land under the same publishing umbrella as (one of my own favorite programming books as well) The Pragmatic Programmer, do you have insight as to whether your title will also be made available on the O'Reilly platform?
- dmuller 5y agoHi - that's a good question about the O'Reilly platform. I can ask my editor and get back to you on that. What's the best way to reach you?
- usrme 5y agoThanks for the reply! You can write to me at usrme(at)protonmail.ch
- dmuller 5y agoIn case it's helpful for anyone else, here's what publishing team had to say: "Yes, your book will eventually show up on the O'Reilly Learning Platform, but it'll be a while still. Most of our books first appear there four to eight weeks after they go into print. So just keep an eye out on OLP, because it's coming."
- Frawzey 5y agoBookmarked. Thanks.
- sireat 5y agoThe chapters look good! How would you compare this book to "Fluent Python"? Similar level? I like "Fluent Python" and it is the recommendation I currently give to my students who want something intermediate.
- dmuller 5y agoI've not read Fluent Python, but its table of contents looks quite extensive, and covers a lot of good ground. Intuitive Python does cover some things that aren't present in Fluent Python (as far as I can tell): checking your code for errors with flake8 + mypy, using pdb to debug, profiling with cprofile, running external programs with subprocess, using the sqlite3 module, tempfile module, datetime + timezones, the Python official Docker images, and pip. Fluent Python's ~800 pages really give great coverage for much of the standard library and patterns your students will see in wild Python, but the more compact ~140 page Intuitive Python might layer on some additional knowledge too.
- slava_kiose 5y agoCongratulations and regards! Complex things are explained in simple language.