Relative imports – ModuleNotFoundError: No module named x

TL;DR: You can’t do relative imports from the file you execute since __main__ module is not a part of a package. Absolute imports – import something available on sys.path Relative imports – import something relative to the current module, must be a part of a package If you’re running both variants in exactly the same way, one of them should work. Here is … Read more

C-like structures in Python

Update: Data Classes With the introduction of Data Classes in Python 3.7 we get very close. The following example is similar to the NamedTuple example below, but the resulting object is mutable and it allows for default values. This plays nicely with the new typing module in case you want to use more specific type annotations. I’ve been waiting desperately for this! If you ask … Read more

What does ‘super’ do in Python? – difference between super().__init__() and explicit superclass __init__()

The benefits of super() in single-inheritance are minimal — mostly, you don’t have to hard-code the name of the base class into every method that uses its parent methods. However, it’s almost impossible to use multiple-inheritance without super(). This includes common idioms like mixins, interfaces, abstract classes, etc. This extends to code that later extends yours. If somebody … Read more

What does !important mean in CSS?

It means, essentially, what it says; that ‘this is important, ignore subsequent rules, and any usual specificity issues, apply this rule!’ In normal use a rule defined in an external stylesheet is overruled by a style defined in the head of the document, which, in turn, is overruled by an in-line style within the element itself (assuming equal specificity … Read more

Web scraping redoc web api

Redoc is a React app which means the actual HTML is being built in runtime: first the skeleton of the page loads, which also loads redoc javascript then the Redoc downloads the OpenAPI json (or yaml) file and renders the actual HTML dynamically based on it This is similar for many apps build with modern JS … Read more

What is the best way to use a HashMap in C++?

The standard library includes the ordered and the unordered map (std::map and std::unordered_map) containers. In an ordered map the elements are sorted by the key, insert and access is in O(log n). Usually the standard library internally uses red black trees for ordered maps. But this is just an implementation detail. In an unordered map insert and access is in … Read more

‘App not Installed’ Error on Android

Primarily for older phones I only encountered the App not installed error when trying to install an apk on my phone which runs on 4.4.2 aka KitKat, but my friend did not encounter this error on his phone which runs on 6+. I tried the other solutions such as removing the old/debug version of the app because … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)