Hacker News new | past | comments | ask | show | jobs | submit login
Intermediate Python (pythontips.com)
335 points by heyalexej on Aug 17, 2015 | hide | past | favorite | 78 comments



Hi guys! I am the author of this book. Thanks heyalexej for posting this here. If there is anything I can help you guys with then kindly let me know. :)


Thank you for making the PDF available.


You are welcome kind stranger! :)


Where can I download it please?

Edit: Never mind - I hadn't noticed you've added targets to the Makefile :) Thanks.


Yes, thank you indeed. I found it very helpful and easy to digest.


Link pls?



You guys can donate me if you want to by buying the donation version of Intermediate Python from [@gumroad](https://gumroad.com/l/intermediate_python) :) It is only for $10 but if you want to pay less then kindly let me know (pm) and I can give you a custom link. Cheers!


Just read the entire thing, good stuff! Interesting to see what's considered intermediate vs. basic and advanced.

Feedback: maybe add a feedback section to the site? Haha. Dissect is spelled with 2 S's, and there's a broken link at the end of the virtualenv section.

Thanks for your work! Learned a few things for sure.


ditto that, I just read the whole thing! I knew some of those tricks and others were new. Thanks!


I get to program python maybe 300 hrs a year. And I love every minutes. But there are times that I wonder if I'm doing it in an idiomatic way. There are a lot of good resources out there on python but this one has helped me a lot in my first 30 minutes of reading it.

Thank You!!!!


I am really happy that it helped! :)


Would be cool to see you demonstrating some of the tips in a livestream on Livecoding.tv.


Brilliant. Every language should have a book like this. I'm already learning a lot of little details about features I've had some passing experience on. Only request I have (which I generally have for stuff like this), is for real life use cases. Example would be args and *kwargs being used in decorators. Where do you use it? What's a real life example of it being used? How does that compare to the in built decorator functionality of Python? Answering this type of question helps people understand the technique and theory in equal measures as opposed to more theory than technique.

Thanks again for this :).


For Java I can recommend Effective Java, that does similar stuff - expects you the basics and shows you idioms and "the right way".

Now I search for a similar book for Haskell


I usually search in code in github for IRL-examples. Sometimes it works just as good.


I use decorators like that in Django where I want to reuse the same code to check something on the request object but the functions I am decorating expect keyword arguments


I've been thinking of something like this for models especially. Where I have made my own models and worked with Flask, but now need to integrate the Django framework. Just a vague idea though. Haven't formed a clear picture of how I'll do it at all


Map and filter are looked down upon by some Python devs because they prefer list comprehensions. If you don't need the laziness (in Python 3 only), you probably shouldn't use them because some don't consider them idiomatic. See this for more information:

http://stackoverflow.com/a/6407222/384700


> If you don't need the laziness (in Python 3 only), you probably shouldn't use them ....

And if you do need the laziness, then you can use generator comprehensions.


Yeah, map and filter not really idiomatic; you're almost always better served by a list/generator comprehension. Even Guido has regrets about map/filter/reduce: http://legacy.python.org/doc/essays/ppt/regrets/PythonRegret....


From related Reddit thread[0]:

Note: This is not related with that paid "intermediate Python" book in any way. I became aware of it today. I had been using this name internally for a couple of months. If the author of paid "Intermediate Python" has any issue with this I would be more than happy to change the name of my book because he definitely beated me to the finish line. :)

[0] http://redd.it/3hbb46


I think you should change it to reduce confusion. "Intermediate Python Programming" should be good enough.


On the other hand, the name "Intermediate Python" is so generic that whoever wrote the book shouldn't be surprised there are other documents using the same name.


A little correction here; intermediate python on leanpub is absolutely free.


Hey! I am sorry. I realized that just now after reading your comment. :)


I love it, as a biologist I did a Python course some months ago, already I'm much more productive than I was in my Origin/Excel time. this books really clarifies many of those strange things (like kwargs etc). This is going straight into my favorites and I know I'll be using it often. Thanx!!!


I love to read such comments. They help to fuel me. :)

Let me know how you use this book! And kindly share it with your peers. Best of luck!


I have put a link to a mailing list. If you want to tip me then kindly signup over there and I would let you know once I have a tip receiving system in place. I already run a reputed [Python Weekly Newsletter](http://newsletter.pythontips.com/) so you are in a good company (meaning I won't spam you).

Mailing list: http://eepurl.com/bwjcej


And if anyone wants to add / enhance this here you go:

https://github.com/IntermediatePython/intermediatePython


    from contextlib import contextmanager
I love this feature, I never forget to close a connection. It can also be useful for monkey patching, or thread local variable based optimizations.


This looks great just from glancing over the table of contents. I picked up Python nearly a year ago and I am a pretty novice programmer at best. Over time I've learned stuff like decorators, lambas, args/kwargs and other stuff that you generally don't find in the "Intro to Python" books, but its all been through stumbling into the right place. Thanks for sharing, I may have something to read this week :)


Shit, what I need is "How to publish a package to PyPi in 3 easy steps."

I go around and round with the Python Packaging Authority's documentation.



Thanks! If you have any suggestions / feedback I'd be happy to hear it – I've been planning on updating the post sometime soon to show how to upload wheels and in general just clean up the language and approach.


It's not bad unless you want to upload detached signatures. Then it's a frantic search to find the right incantation to make it work.


thanks! that looks super easy. last time i tried, i rage-quit.


It has been much more difficult in the past, as recently as 2013, there were a number of different tools competing to be the standard method of packaging python. It's pretty smooth sailing at this point.

I actually gave a lightning talk on this topic a couple months ago. Here are my slides, in case they're useful: https://docs.google.com/presentation/d/13Cd-LIcw38d-zwZ5pGiW...


Great job @yasoob! What's even more amazing, even thought not directly relevant, is that the author is still in high school.


I just skimmed through decorators. I don't use python too much and decorators always seemed a little bit black magic for me. Thanks for proving this wrong.


You guys can donate me if you want to by buying the donation version of Intermediate Python from [@gumroad](https://gumroad.com/l/intermediate_python) :)

It is only for $10 but if you want to pay less then kindly let me know (pm) and I can give you a custom link.

Cheers!


Thanks for this! It's really good to have intermediate stuff all in one place, rather than tutorials on a specific topic


Nice, I've shared it in my social networks.

As for a supposed "Advanced Python" edition, it would be great to compile at least a list of topics that could be interesting. Some have been already mentioned in this thread, like:

  - Metaclasses
  - Packaging (for pypi)
I'd add:

  - Must-have libraries
  - Testing


Whilst I don't buy into the TDD fad, Testing should not be an advanced topic.


Test Driven Development (TDD) may or may not be a fad. Regardless, one can always have testing in ones development work. That doesn't mean you're driven by the tests.

Edit: On second thought, I read your comment sloppily. I agree, testing in itself isn't an advanced topic and I'd recommend a section on some testing :-)


What don't you buy about TDD?


There is "Expert Python Programming" (https://www.packtpub.com/application-development/expert-pyth...). Some of the material is dated, but I'm sure it would be a good place to start as far as gathering topics for further study.


Asyncio, for sure.


I like it. Really good.

The only point, I might not consider lists being mutable nor global values vs values returned from a function intermediate topics. Those are beginner topics I think.. one would have a hard time using the language almost at all without understanding them. I would say the part about decorators and kwargs args is more intermediate level. Anyone who gets to that probably already understands global variables and the fact certain data structures are mutable.

But not abuse your work. The book is nice. I learned a couple of things.


Hey! There is no problem with correcting me. If you think that I missed something or if there is something that can be improved and you think that you can make it much better then submit a pull request if you can. :) I would be more than happy to accept it.

Here is the GitHub repo: https://github.com/IntermediatePython/intermediatePython


Arguable. I doubt most intermediate programmers know much about tuple/string immutability


Really good stuff here, and well put together.


Is there anything like this site for Java?


Effective Java by Joshua Bloch



I see that that the book has a section on usage of For-Else construct. Personally I found this construct to be confusing, and avoid its usage as one can achieve the same by setting a flag (say). Is this construct much used ?


No. It is not used widely. AFAIK.


Then probably it might be a good idea to add a note about avoiding its usage in your book. Thanks for the book and making it available for free.


Another "Intermediate Python" book: http://www.amazon.com/dp/149055095X


Is this another book, too? https://leanpub.com/intermediatepython very confusing


Author here! This is totally unrelated to the posted book.


That is totally different from my book :) I haven't read it so I can not tell how much different it is from mine. Perhaps you can tell if you have read it?


I was right about to buy it, completely blind, based on the similar title, because a good deed deserves a good deed: I support anyone who gives their book away for free online and offers a hard-copy (Learn You a Haskell, I'm looking at you) for purchase.

Let me know if you have an Amazon affiliate link, tipjar, or need help with any projects.

Edit: whoa, at least 5 redditors had the same "do you have a paypal?" sentiment. I suggest you have a header on visit and start collecting opt-in emails. That way, people like me will be emailed the second you get all setup.

Edit 2: Also, this definitely is a good "resume" for consulting work. I'd put an "Available for Hire/Retainer" notice at the header of every page, in case someone has an overflow of work, and/or a corporate manager wants a flexible contractor asset available as an insurance policy for behind-schedule projects. Don't charge less than 150/hr in 20 hour blocks per month for retainer work (use it or lose it), and 175ish/hr for active work.


https://leanpub.com/intermediatepython author here.. Did you get to take a look at the book? It is actually free of charge on Leanpub


I think your book goes for breadth of topics while his primarily focuses on solid understanding of iterators, generators, and decorators.

p.s. I only looked at the "Enumeration" page in your book, and I don't think it belongs in an "intermediate" level Python book. The use of optional arguments makes little sense to me (not something I wanted to know about Python after I learned the basics).

I'm sure other chapters have more relevant content though, and I appreciate your effort.


I consider myself somewhere in the spectrum between beginner and intermediate and I use enumeration quite often. I picked it up early on in a tutorial by Andrew Montalenti (founder of http://www.parsely.com and quite active in the Python community) and use it ever since instead of wrapping it into another loop like beginner tutorials teach you. For example if I need to read in a file with 5 million lines but for debugging or performance optimization reasons want to break the loop after 1K lines.


All beginner tutorials I used introduced "enumerate" early on.

Indexing is probably the first thing you're wondering about when you start coding in Python after coding in C.


This is great! You can make an ipython notebook version of this too.


Really good stuff in here, thanks for this. Are there any plans to follow this up with something along the lines of "Advanced Python"?


Just go read David Beazely's site for that. Seriously

http://www.dabeaz.com/blog.html

A few good ones for reference:

http://www.dabeaz.com/generators/

https://www.youtube.com/watch?v=fwzPF2JLoeU


I love his work and I honestly recommend it to you guys! :)


I don't have any plans right now but I might think about it.


It's interesting how a search for "metaclasses" in the given link doesn't yield any results.


That is advanced level stuff :) If you want to add it to this book then kindly go ahead. This book is open source.


It's certainly an arduous task to determine what is intermediate and what isn't! And I think you did an excellent job, from looking at the table of contents (I'll have to take a closer look and have booked marked it for later). Unlike some the above posters, I learned metaclasses relatively early, but there are definitely some things in this book which I haven't seen before. Thank you.


That's a pretty advanced topic. Like a lot of advanced (and some intermediate) topics, you read a bunch of varying documentation and play around with it yourself before you get a good grasp.

For me, one of the more useful things were these slides that talk more about the when and why instead of the how: http://www.vrplumber.com/programming/metaclasses.pdf


Perhaps the author thought metaclasses are Advanced Python.


I'd tend to agree. I've been writing Python for years, and I still haven't had a legitimate use for them. Not to say that there's no use for them, they're handy when implementing an ORM. However, it's not often that you'd need to do something like that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: