Hot answers tagged

3 votes
Accepted

Properly "exposing" a variable from a class in Python

A class becoming "bloated" is not a good reason to expose internal data if the methods are still cohesive. While a large class can indicate it is doing too much, is is not an automatic ...
user avatar
2 votes

TL suggests that testing, refactor, and tool usage could avoid the need for verbose logging

The reason you're depending on this verbose logging is that you need to be able to make sense of the flow of the code. Therefore, the flow must logically be very complex and/or cluttered without this ...
user avatar
  • 37.3k
2 votes
Accepted

How to use lazy import to speed up a list of known types in python?

The easiest solution is indeed going to be to describe the model via strings describing the module that you then import. For example, something like: import importlib KNOWN_TYPES = { "kmeans&...
user avatar
  • 123k
1 vote

How to handle config/env vars in a library project

There is no single best way, because it depends on the architecture of the library. Reading environment variables directly in library code is also problematic for writing unit tests, which is another ...
user avatar
1 vote

Why does CPython has both C and .python versions of modules?

C code is real code, python is interface code. The c code is the performant code, while the python is for python runtime to correctly handle call sites. Also use the c code Version to get the most ...
user avatar
  • 92
1 vote
Accepted

What is a good way to call a unit-tested function provided by a library/package?

Encapsulating library functions makes most sense when your "own" interface main offers simplified access to the library, or at least provides a more precise or more readable name (assuming ...
user avatar
  • 184k
1 vote

TL suggests that testing, refactor, and tool usage could avoid the need for verbose logging

The alternative to verbose logging is (obviously) limited logging - and this is really only helpful when you can look at what you do log and pinpoint the exact cause of the problem you're trying to ...
user avatar
  • 4,360
1 vote

How to properly isolate tests for dataframes with grouping?

More generally what you are describing is a Data-Driven Test. To echo Kilian Foth's comment, each data frame is not a separate test case. Each data frame represents a different input to the same test ...
user avatar

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