J
Jeff Knupp
jeffknupp.com · Personal blog · on HN since 2012
Jeff Knupp, a Python developer and author, writes about idiomatic Python, the language's execution model, Django, and DevOps.
What HN saysHN commenters recommend his posts as good, in-depth explanations of Python's name binding model and of setting up a Django project.
90HN people shared it
29linked it in comments
109stories submitted
1.9Kstory points
3 years agolast shared
2012people per year2026
Most-shared posts
- 1How 'DevOps' Is Killing The Developer8 people · 500 points · first shared 2014 · 209 comments on HN
- 2Writing Idiomatic Python Book8 people · 79 points · first shared 2013 · 18 comments on HN
- 3Write Cleaner Python: Use Exceptions5 people · 11 points · first shared 2013 · discussion on HN
- 4Writing Idiomatic Python5 people · 9 points · first shared 2012 · discussion on HN
- 5Python's Hardest Problem (2012)4 people · 124 points · first shared 2012 · 70 comments on HN
- 6Starting a Django Project the Right Way4 people · 118 points · first shared 2012 · 49 comments on HN
- 7Is Python call-by-value or call-by-reference? Neither.4 people · 42 points · first shared 2012 · 65 comments on HN
- 8Drastically Improve Your Python: Understanding Python's Execution Model4 people · 18 points · first shared 2013 · discussion on HN
- 9Open Sourcing a Python Project the Right Way4 people · 11 points · first shared 2013 · 5 comments on HN
- 10Why I Hate HATEOAS4 people · 6 points · first shared 2014 · 2 comments on HN
- 11Python and Flask Are Powerful3 people · 261 points · first shared 2014 · 75 comments on HN
- 12Sandman: A Boilerplate-free Python REST API for Existing Databases3 people · 97 points · first shared 2013 · 19 comments on HN
- 13Python is the fastest growing programming language due to buffer protocols3 people · 29 points · first shared 2017 · 6 comments on HN
- 14Python with Context Managers3 people · 17 points · first shared 2016 · discussion on HN
- 15Python's Hardest Problem, Revisited: mitigating the effects of the GIL3 people · 9 points · first shared 2013 · discussion on HN
What HN people wrote when they linked it
jonesetc · 2014-02-21
> Start a blog where you share progress on your project. This will hold you accountable and let people know what you’re working on.
For a long time I wrote off the idea of having a blog because it seemed vain. I don't usually have any great ideas that anyone else needs to know about, and my trials of learning new things are just the same as everyone else's. However, over the past few months I've realized that I was dead wrong. Watching a few good series of blogs like [1] and [2] has shown me that even if you don't have anything world shattering it is still great as a means to make learning more important. After all, you can't let down your readers, can you?
[1] http://jvns.ca/blog/2013/09/26/hacker-school-day-4-c-unit-testing/
[2] http://www.jeffknupp.com/
gregmac · 2016-07-19
Agreed, and specifically:
> APIs will continue to be a disparate system that requires custom code for every integration until we can embrace the full benefits of REST
Have an example of a client that DOESN'T require custom code to use an API?
I think this entire debate is summed up best by:
> There is no magical "smart client" that somehow knows that rel=comments means that the link leads to comments about the current resource and can figure out it should POST there to create a new comment. It has no idea what the hell a "comment" is. [1]
[1] https://jeffknupp.com/blog/2014/06/03/why-i-hate-hateoas/
bufordsharkley · 2015-09-26
I recommend this article going into good depth on how Python's name and binding model functions:
https://www.jeffknupp.com/blog/2013/02/14/drastically-improve-your-pyt…
julezy1 · 2014-04-01
This guy wrote a great article a while back [1], great to see him turning this into a book.
I wish this kind of thing would go into the core python documentation though. So new Python programmers learn to 'think' python.
---
[1] http://www.jeffknupp.com/blog/2012/10/04/writing-idiomatic-python/
zpk · 2013-02-03
If you want a good start to Django follow this guy's setup. The virtual env made managing my libraries a lot easier.
http://www.jeffknupp.com/blog/2012/02/09/starting-a-django-project-the…
Rails the framework I think is better than Django. I just found conceptually it had more of what I wanted already in there. However coming from a Java/Perl background, Python was easier for me to grasp and read over Ruby. And timing wise, I wouldn't deploy or upgrade a Rails app until I felt comfortable with the security issues being addressed. Hell, I wouldn't want to surf the internet with an app running on my computer today.
Jugurtha · 2021-03-27
It depends what you used to do with Python, really. There are a lot of users whose code didn't change from 2.x to 3.x except for the print "statements".
I replied to similar threads[0][1], reproduced here:
"""
The Python documentation is pretty cool. I frequently go to Chapter 3 (Data Model) and always learn something new reading something I had already read but didn't quite get.
The mailing list has top notch posters who are always willing to help.
The IRC channel (#python) has very helpful members who've been patient with me on more than one occasion.
Books:
Stacking the deck:
"Python Guide" - Kenneth Reitz: The bits one doesn't necessarily think about but that simplify life: virtual environments, unit test, project structure, good practices, scenarios for different kinds of applications, documentation, etc.
Doing stuff:
"Python Cookbook" (several editions by different authors, Alex Martelli and David Beazley): as the title states, it's a cookbook that shows you how to do a bunch of stuff in Python (files, network, threads, etc). This can get you "operational" in Python pretty fast.
Doing stuff well (meta):
"Writing Idiomatic Python" - Jeff Knupp:
The book comes for Python 2 and Python 3 and contrasts "harmful" and "good". Jeff Knupp also has videos showing you the process of refactoring code. He also has a blog (https://jeffknupp.com/) where he addresses many topics.
"Effective Python: 59 Specific Ways to Write Better Python" - Brett Slatkin: Pretty good…
no_wizard · 2017-01-22
May I suggest this book specifically tailored for python best practices? https://jeffknupp.com/writing-idiomatic-python-ebook/
Its a wonderful read. Will really unleash the pythonista inside of all us!
If you really want to go deeper, I suggest these as well:
https://goo.gl/CY6zPu
https://goo.gl/UbMrTb
Those shortened links take you to amazon (not affiliated in any way, FYI, just though the length of the URLs was obnoxious)
Those are the definitive python programming books I came up with anyway.
While we are at, I have to say once I learned to really code Pythonically I find that I can apply the PEP8 standards to almost any language. Admittedly, I, like John Siracusa, am a top level language debutante and don't live in C or C++ production code (I sometimes use objc but swift is...easier :). I remember learning C, and thanks to arduino I certainly using some varient of C/c++ there more heavily, but my coding style follows more or less the pythonic standard (with PEP8 being the backbone of that).
food for thought, people of hacker news!
brianpgordon · 2014-04-16
This is in pretty stark contrast to yesterday's article about devops:
> Somewhere along the way, however, we tricked ourselves into thinking that because, at any one time, a start-up developer had to take on different roles he or she should actually be all those things at once.
> What began as an experiment aimed at increasing software quality has become a farce, where the most talented employees are overworked (while doing less, less useful work) and lower-level positions simply don't exist.
> Large companies love this, as it means they can hire far fewer people to do the same amount of work. In the process, though, actual development becomes a vanishingly small part of a developer's job.
http://jeffknupp.com/blog/2014/04/15/how-devops-is-killing-the-develop…
I certainly wouldn't be happy with a developer position that made me do tier 1 customer support. That stinks more of "absurdly cheap" than "connecting with customers."
leetrout · 2024-02-16
Links for anyone else interested as I was
https://jeffknupp.com/writing-idiomatic-python-ebook/
https://docs.quantifiedcode.com/python-anti-patterns/
williamsmj · 2023-08-30
I think you're describing a symptom (popularity in data contexts) rather than a cause. If you're looking for causes, https://jeffknupp.com/blog/2017/09/15/python-is-the-fastest-growing-pr… makes a good case the answer is PEP 3118.
LrnByTeach · 2019-10-13
> So "make your programs shorter" also implies "make bad behaviors impossible or extra-verbose to write".
It reminds me "The Zen of Python"
"There should be one — and preferably only one — obvious way to do it"
https://jeffknupp.com/blog/2018/10/11/write-better-python-functions/
https://towardsdatascience.com/how-to-be-pythonic-and-why-you-should-c…
nwatson · 2019-05-17
No HATEOAS? https://en.wikipedia.org/wiki/HATEOAS
I don't think full-on HATEOAS is practical, and blog (https://jeffknupp.com/blog/2014/06/03/why-i-hate-hateoas/) says it well: "When designing a hypermedia API [per HATEOAS standards], you're really designing for a client that does not, and will never, exist." There are some good ideas there though.
chillacy · 2019-02-12
Counterargument: Exceptions are Pythonic https://jeffknupp.com/blog/2013/02/06/write-cleaner-python-use-excepti…
gyani95 · 2018-08-17
Google's Python class is a pretty good start[0]. It's enough to get you started and moves at a nice pace! After that I'd hack on a project of my own. Even better if you have a project in mind before learning the language. This book by Jeff Knup will get you familiar with the pythonic way of doing things[1].
[0]https://developers.google.com/edu/python/
[1]https://jeffknupp.com/writing-idiomatic-python-ebook/
shakna · 2017-09-14
Use "type".[0]
The last argument should be the dict that __INIT__ is usually responsible for creating.
[0] https://jeffknupp.com/blog/2013/12/28/improve-your-python-metaclasses-…
ackerman80 · 2017-07-27
freyr · 2017-05-23
Also, strictly speaking, Python is not "pass by reference" as the term is used for other languages. It's more accurately "pass by object" or "pass by object reference." Somewhat of a pedantic distinction, and the quiz question is clear regardless.
[1] http://robertheaton.com/2014/02/09/pythons-pass-by-object-reference-as…
[2] http://foobarnbaz.com/2012/07/08/understanding-python-variables/
[3] https://jeffknupp.com/blog/2012/11/13/is-python-callbyvalue-or-callbyr…
AbhishekBiswal · 2014-09-13
Since you mentioned Django, why not try out Flask?
http://www.jeffknupp.com/blog/2014/01/18/python-and-flask-are-ridiculo…
jw2013 · 2014-07-18
This is all in Jeff Knupp's Writing Idiomatic Python:
http://www.jeffknupp.com/blog/2012/10/04/writing-idiomatic-python/
Many so-called Python Idioms are really non-intuitive and I don't really appreciate.
tankenmate · 2014-07-04
jackmaney · 2014-01-30
Although many of them boil down to preferences and philosophical points of view, I find these kinds of idioms useful. Whenever I write code in a new language, I want to "write as a native" so that I can maximize the effect that the language has on how I think about programming.
For Python in particular, Jeff Knupp's "Writing Idiomatic Python"[1] (not free, but not expensive, either) goes into detail on a lot of the concepts in the OP's slides. (I'm not affiliated with Jeff in any way, just a satisfied customer.)
[1] http://www.jeffknupp.com/writing-idiomatic-python-ebook
__derek__ · 2013-12-31
Or use exceptions to write cleaner code: http://www.jeffknupp.com/blog/2013/02/06/write-cleaner-python-use-exce… That post is specific to Python, which actually implements a lot of internal features using try-except, but it suffices as an argument against the idea that catching exceptions is itself a bad practice.
FlukeATX · 2013-03-26
Another good post: http://www.jeffknupp.com/blog/2012/10/24/starting-a-django-14-project-…
That one covers virtualenvwrapper, too, on top of virtualenv, so you don't have to deal with that cruft in your project directory at all.
alienreborn · 2013-03-13
saurik · 2017-10-12
https://jeffknupp.com/blog/2017/09/15/python-is-the-fastest-growing-pr…
> Python's Buffer Protocol: The #1 Reason Python Is The Fastest Growing Programming Language Today
> The buffer protocol was (and still is) an extremely low-level API for direct manipulation of memory buffers by other libraries. These are buffers created and used by the interpreter to store certain types of data (initially, primarily "array-like" structures where the type and size of data was known ahead of time) in contiguous memory.
> The primary motivation for providing such an API is to eliminate the need to copy data when only reading, clarify ownership semantics of the buffer, and to store the data in contiguous memory (even in the case of multi-dimensional data structures), where read access is extremely fast. Those "other libraries" that would make use of the API would almost certainly be written in C and highly performance sensitive. The new protocol meant that if I create a NumPy array of ints, other libraries can directly access the underlying memory buffer rather than requiring indirection or, worse, copying of that data before it can be used.
(The italic emphasis was copied from the original article.)
boramalper · 2017-08-24
> We can use the Python built-in function id which returns a value you can think of as a memory address to investigate.
> [...]
> It looks like there is a table of tiny integers and each integer is takes up 32 bytes.
It is the memory address but it's a "CPython implementation detail: This [return value of the id() function] is the address of the object in memory."[1]
Though you cannot use this to determine the size of an object, or rather you "shouldn't" because that assumes a very specific implementation detail, which isn't there.
If you'd like to get the size of an object, use sys.getsizeof().[2] Also keep in mind that containers in Python does not contain the objects themselves but references to them so the returned size is the size of the object itself only, non-recursively. Read "Is Python call-by-value or call-by-reference? Neither."[3] for some more details.
[1]: https://docs.python.org/3.6/library/functions.html#id
[2]: http://docs.python.org/3.6/library/sys.html#sys.getsizeof
[3]: https://jeffknupp.com/blog/2012/11/13/is-python-callbyvalue-or-callbyr…
boyaka · 2015-09-09
Warning: I am neither a skilled nor experienced programmer. I would say the kernel of programming languages is more practically something like C, assembly, or machine language. Kernel implies containing the core functionality, the building blocks. Van Roy's kernel language does seem to contain core ideas for ideal programming languages, even though it doesn't seem to translate well to existing hardware / machine language.
After reading a bit about it I started to think of it as pseudocode for programming languages, and I thought I'd share some results from my searching based on that idea [1].
"In terms of the kernel language itself, it is in fact its own programming language, a sort of "runnable pseudocode" that is executable in the Mozart/Oz platform."
Here's an interesting link I found by searching for database pseudocode [2]. This delves into the topic of "NoSQL", which might be helpful in your database basics research, but it also covers other database basics.
I am also not very skilled nor experienced with databases, but based on your request, one database that comes to mind for me is Berkeley DB. It is the building block for lots of other technologies, and is also considered one of the origins of the NoSQL concept. Here's a recent relevant discussion that probably made me think of it [3] (that and it is the basis for a distributed filesystem I'm studying). Also, check out the Wikipedia for it, and (maybe obvious to you already) searching site:news.ycombinator.com…