8 stackoverflow threads to read for deeper understanding of Python
Stackoverflow is a great resource for beginners of programming. But what is underestimated is, the quality content on the site for intermediate programmers. Here I list down few suchquestions, which have helped me immensely in advancing my python learning journey beyond the basics.
- Except:pass — Catching any exception and not doing anything, is used as an escape mechanism when you dont know how your try: block will work. However, any experienced pythonista will get irritated on seeing it. Delve deeper into this stackoverflow thread to know so.
- Super() in multiple inheritance — Understadning the behaviour of super is straight forward in case of single inheritance. Since python is one of those languages that support multiple inheritance, the world of Super() gets a bit murky.
- Demystifying decorators — Decorators are immensely useful for adding common functionality to functions. Read this thread thoroughly to know what lies beyond simple and straight forward uses of decorators.
- Understanding self — explicit is better than implicit. An explicit self doesnt feature in any of the other OOP languages.
- Mutable default argument — This is one of the places where every python beginner gets stumped, twice.
- *, ** unpacking operators — Although much of the functionality is new in python3.5. * and ** have been there since python2 inside function arguments.
- MetaClasses — Just like objects are instances of classes, classes are themselves first class objects, ie instances of special set of classes called metaclass.
- Single and double underscores in naming — Also called dunder, double underscores as prefix and suffix have special meaning in python. e.g. __init__, __str__, unlike single underscore as prefix like _pvt_var, which is a signal for private-ness of the name/method.