Hot answers tagged

3

In general you should be more especific on the management of the exceptions, my only contribution will be to be more specific on them on the requests component. For example your code on: def get_api_data(url): try: response = rq.get(url) response.raise_for_status() ... except Exception as e: logger.debug("...


3

If you want a cleaner version of dynamic/ExpandoObject, I would go step by step and fix what you don't like. Let's say you want to do something close to a Javascript-like syntax: obj = {}; obj.a = 123; obj.b = "message"; obj.c = [ 456, "something", {} ]; obj.d = { x: 50, y: [ "a", "b", "c" ], z: null }; obj.e = "eeee"; obj.d.z = { z: "zz" }; ...


2

I like the simplicity of this code. It may needs some improvements, but these are just to make it more flexible to be adopted to other projects (if it's intended for that). For most part, you've put the main functionalities on an extension class, which is something I wouldn't do myself. I think It would be better if Add, Remove, Get, and Set ...


2

When using the logger module, you usually want to initialize the logger once per script, at the beginning, and usually with the name of the file (or another descriptive name) as the argument. This way you can distinguish where each logging call comes from (although you have disabled that with your particular choice of formatting string). Since you are ...


1

Hellow K.H. thanks for the answer. I rewrote the code using Dagger 2 for dependency injection and following your advice. Could you take a look at this code and answer a couple of questions: How to correctly pass name to JsonSharedPreferences (Make a setter, make a module that will provide name). Is it correct to select this code as a separate component or ...


1

Why saving reference to Context and then create SharedPreferences each time? There's duplicate code for creating SharedPreferences You could just use context in constructor to create member SharedPreferences to use in your methods. If you want to keep it as it is, at least extract duplicate code into separate method. I am missing null checks. I expect to get ...


1

You are basically making your object filtering into an \$0(m * n)\$ complexity function ( where \$m\$ is number of type id’s) that your are filtering against and \$n\$ is number of objects in the fetched result set. This function should only be \$0(n)\$. To do this, make type id’s into a Set which allows \$O(1)\$ lookup and then use this Set to filter ...


Only top voted, non community-wiki answers of a minimum length are eligible