Python – multiple inheritance of classes divided into modules

I have a class Main that benefits fn(cls, ...) Methods from several modules; They are used exclusively by Main. Each module is 500-1000 lines long (without document strings). The idea is to "separate" different ones Main Methods to simplify debugging and readability instead of putting them all in one class and creating a file with more than 9000 lines.

Everything works properly. However, one key good is sacrificed: Introspection;; help(Main.method), or also Main.method() are no longer an option. The goal is therefore as follows: keep methods in separate files, but behave like normal class methods.


My approach: Pack module methods into classes, then module classes into a unifier class and inherit the unifier in Main. Code below. Points to note:

  • No overarching problems; Module Classes only contain their methods __init__ is as minimal as shown
  • No attributes like above and therefore the same for Unifier
  • No duplicate attributes / methods; All methods are clearly named (and no attributes need to be duplicated).

question: any reservations to consider? What can you do better? Some special concerns are:

  1. Is pickle.dump, .load affected? I only stain non-method Main Attributes.
  2. It's a dynamic to_unify reliable? I assume it depends on how all the classes involved change.
  3. Any complications of the metaclass from the inheritance scheme?

code: Live demo

# module_a.py
class ModuleA():
    def __init__(self):
        super(ModuleA, self).__init__()

    def woof(self):
        """I'm a dog"""
        self.do_woofing()  # dependency on ModuleB

    def do_dooting(self):
        print("DOOT")
# module_b.py
class ModuleB():
    def __init__(self):
        super(ModuleB, self).__init__()

    def doot(self):
        """I'm a skeleton"""
        self.do_dooting()  # dependency on ModuleA

    def do_woofing(self):
        print("WOOF")
# main_module.py
from module_a import ModuleA
from module_b import ModuleB

to_unify = ModuleA, ModuleB  # can add modules later

class Unifier(*to_unify):
    def __init__(self):
        super(Unifier, self).__init__()

class Main(Unifier):
    def __init__(self, *args, **kwargs):
        super().__init__()
        # ...
# main.py
from main_module import Main

m = Main()
m.woof()
m.doot()
help(m.doot)
WOOF
DOOT
Help on method doot in module module_b:

doot() method of main_module.Main instance
    I'm a skeleton

Why Entropy is Divided by 32 (Seed to MNEMONICS)

I want to create a seed phrase (mnemonic) from entropy. An aspect of BIP39 the checksum must be created and described as follows (Link BIP39):


The mnemonic must encode the entropy in a multiple of 32 Bits. With more
Entropy, security is improved, but the sentence length increases. We
Refer to the initial entro length as an ENT. The allowed size of ENT is
128-256 bits First an initial entropy of ENT Bits are generated. A
The checksum is generated by the first ENT / 32


This thread describes many details, but not why dividers 32 (or I don't understand).
I am not a cryptographer and have not found a detailed description of why the divider 32 was selected. My guess is entropy. But why exactly?

Configuration divided into multilingual sites and sites with multiple domains

I want to run 30 Drupal 8 websites, each website runs on a different domain.

The locations are similar with small differences.

The websites are multilingual.

Some of them have 2 languages, others more.

I want (must) that all be managed with a unique code base (using GIT, Composer and Docker).

I use the config_split module to split the changes between the different locations.

Can I split languages? Which variables must be excluded / ignored so that the other sites are not overwritten after each new deployment?

Sell ​​- hostworld.uk – VPS Launch Special – £ 12 OFF! | SSD | 24/7 support | VPS | Divided

Hi there!

We recently launched our brand new SSD VPS plans (see special offer below!). If you are looking for regular shared and reseller hosting, visit https://hostworld.uk/web-hosting or https://hostworld.uk/reseller-hosting. We also provide dedicated servers.

We are hostworld.uk and a UK based web hosting provider. Let's get down to business, here are some important things you can do need Find out about us before buying our plans and join us on your VPS hosting journey:

  • 24/7 support and lightning-fast ticket responses – We respond to all support tickets within 20 minutes on average!
  • We only use the latest generation of SSD drives in all of our servers – no moving parts mean faster service for you!
  • Servers in the UK – We currently offer our services in UK data centers that offer super fast connectivity even if you don't live here!
  • We really care about your hosting experience – talk to us, send us an email, pick up the phone. We are real people who strive to offer each and every one of our customers a consistent and reliable hosting experience, no matter how much you spend on hosting with us.
  • We are reliable! We offer a 99.9% uptime guarantee as it is imperative to ensure that your website is available. You can see our availability here https://status.hostworld.uk/.

If you would like to know anything else about us, send an email to and we will get back to you!

————————————————– ——
VPS Start Special
————————————————– ——

To celebrate the launch of our brand new SSD VPS plans, we offer a special VPS starter pack. See below for details:

For just £ 9.99 a month you can complete the following offer, which is usually £ 22.55 a month!
SEMrush

2 vCPU
100 GB SSD hard drive
4 GB RAM
Free 300 GB backup storage
Unmeasured bandwidth
Fast 1 Gbit / s uplink
Selection of operating system and control panel

Order now – more information

Hurry up, this offer is only available until 1/19/20 11:00 PM.

————————————————– ——
What other SSD VPS packages do we offer?
————————————————– ——

SSD VPS-1

2 vCPU
30 GB SSD hard drive
1 GB RAM
Free 90 GB backup storage
Unmeasured bandwidth
Fast 1 Gbit / s uplink
Selection of operating system and control panel

Only £ 5.99 a month!

Order now – more information

SSD VPS-2

2 vCPU
50 GB SSD hard drive
2 GB RAM
Free 150 GB backup storage
Unmeasured bandwidth
Fast 1 Gbit / s uplink
Selection of operating system and control panel

Only £ 9.99 a month!

Order now – more information

SSD VPS-3

4 vCPU
100 GB SSD hard drive
4 GB RAM
Free 300 GB backup storage
Unmeasured bandwidth
Fast 1 Gbit / s uplink
Selection of operating system and control panel

Only £ 19.99 a month!

Order now – more information

SSD VPS-4

4 vCPU
150 GB SSD hard drive
6 GB RAM
Free 450 GB of backup storage
Unmeasured bandwidth
Fast 1 Gbit / s uplink
Selection of operating system and control panel

Only £ 26.99 a month!

Order now – more information

SSD VPS-5

6 vCPU
200 GB SSD hard drive
8 GB RAM
Free 600 GB backup storage
Unmeasured bandwidth
Fast 1 Gbit / s uplink
Selection of operating system and control panel

Only £ 34.99 a month!

Order now – more information

SSD VPS-6

8 vCPU
250 GB SSD hard drive
16 GB RAM
Free 750 GB backup storage
Unmeasured bandwidth
Fast 1 Gbit / s uplink
Selection of operating system and control panel

Only £ 45.99 a month!

Order now – more information

Each SSD VPS plan we offer includes the following by default:

  • Immediate activation – Order from us and the server is ready for use within minutes.
  • A choice of operating systems – choose from CentOS, Ubuntu, Debian, Fedora and Webuzo.
  • Preinstall a Control Panel – Let one of the leading Control Panels install automatically when you order your VPS. Choose between cPanel, Plesk, Webmin, Interworx, ISPConfig or CentOS Web Panel (depending on the operating system compatibility).
  • Automatic backups – We offer a weekly backup of your VPS server as standard and keep 3 of these backups at all times. You can even upgrade to daily backups for just 15% of your baseline costs.
  • Competent support around the clock – we are there for you when you need us every day of the year and at every turn. We will always try to help you out of a difficult situation.
  • DDoS protection as standard – we don't let you pay for the luxury of DDoS protection. By default, the network we use is protected by the world's leading manufacturer of DDoS and cyber threat services.
  • Industry-leading control panel – We offer a self-service control panel in our portal that allows you to stay in control.
  • Super fast SSD based KVM VPS server.
  • Customize your VPS – customize your VPS package to your needs. Add additional memory, possibly a little more RAM, and do everything you can to increase the number of vCPU cores. It depends on you.
  • Upgrade & downgrade at any time – we want to keep things simple; So you can update your VPS package again at any time.

Would you like more information or do you need something that is not listed? Go to https://hostworld.uk/ssd-vps or send an email to

————————————————– ——
What do people think of our hosting services?
————————————————– ——

————————————————– ——
payment methods
————————————————– ——

We currently accept payments through the following:

  • PayPal
  • Credit / debit card
  • Bank Transfer
  • Apple Pay
  • Bitcoin

All plans come without contracts! Questions or sales inquiries? Call us on (+44) 0800 678 5914 or email us , If you need offers other than those listed above, please contact our sales department for an individual offer.

Sincerely yours,

hostworld.uk team

c ++ – Check if neighbors are active in spatially divided voxelization

I have a voxelization that I have to write out in a binary STL file. These voxels are located in a higher-level 3D grid, with each cell in the grid consisting of voxels. Individual cells may or may not contain active voxels.

I optimized the file size considerably by not writing triangles for inner surfaces – areas between active voxels.

However, the method I have used is very ugly and I think it could be improved. I'm not sure if there is an applicable design pattern or just a better way to think about it.

  • It's ugly
  • It is repeating

Regardless, I want to learn something from this code and see how I can do better in the future.

The note spacing may be a bit strange if you use the clang format and a limit of 80 characters.

writeVoxelSTL ():

void writeVoxelAsSTL(
    std::ofstream& fileStream,
    unsigned& numTris,
    const unsigned xCell,
    const unsigned yCell,
    const unsigned zCell,
    const unsigned xVoxel,
    const unsigned yVoxel,
    const unsigned zVoxel) const
{
  // Now need to check if each of its sides need to be written out
  bool left = isNeighborActive(
      xCell, yCell, zCell, static_cast(xVoxel) - 1, yVoxel, zVoxel);
  bool right =
      isNeighborActive(xCell, yCell, zCell, xVoxel + 1, yVoxel, zVoxel);
  bool bottom = isNeighborActive(
      xCell, yCell, zCell, xVoxel, static_cast(yVoxel) - 1, zVoxel);
  bool top = isNeighborActive(xCell, yCell, zCell, xVoxel, yVoxel + 1, zVoxel);
  bool front = isNeighborActive(
      xCell, yCell, zCell, xVoxel, yVoxel, static_cast(zVoxel) - 1);
  bool back = isNeighborActive(xCell, yCell, zCell, xVoxel, yVoxel, zVoxel + 1);

  Point minPoint = highLevelGridMinpoint;

  // Center of the voxel
  Point center;
  center.x = minPoint.x + (((xCell * cellDim.x) + xVoxel) * voxelWidth);
  center.y = minPoint.y + (((yCell * cellDim.y) + yVoxel) * voxelWidth);
  center.z = minPoint.z + (((zCell * cellDim.z) + zVoxel) * voxelWidth);

  // From this center, we can get the 8 corners of the voxel and thus the 12
  // triangles

  // They are defined like this:
  //              7-------6
  //             /|      /|
  //            4-+-----5 |
  //            | |     | |   y
  //            | 3-----+-2   | z
  //            |/      |/    |/
  //            0-------1     +--x

  Point p0(center.x - halfVoxel, center.y - halfVoxel, center.z - halfVoxel);
  Point p1(center.x + halfVoxel, center.y - halfVoxel, center.z - halfVoxel);
  Point p2(center.x + halfVoxel, center.y - halfVoxel, center.z + halfVoxel);
  Point p3(center.x - halfVoxel, center.y - halfVoxel, center.z + halfVoxel);
  Point p4(center.x - halfVoxel, center.y + halfVoxel, center.z - halfVoxel);
  Point p5(center.x + halfVoxel, center.y + halfVoxel, center.z - halfVoxel);
  Point p6(center.x + halfVoxel, center.y + halfVoxel, center.z + halfVoxel);
  Point p7(center.x - halfVoxel, center.y + halfVoxel, center.z + halfVoxel);

  // Now for the 12 triangles made of these points

  // Left side
  if (!left)
    {
      writeTriangleSTL(fileStream, p0, p3, p4);
      writeTriangleSTL(fileStream, p3, p4, p7);
      numTris += 2;
    }

  // Right Side
  if (!right)
    {
      writeTriangleSTL(fileStream, p1, p2, p5);
      writeTriangleSTL(fileStream, p2, p5, p6);
      numTris += 2;
    }

  // Bottom Side
  if (!bottom)
    {
      writeTriangleSTL(fileStream, p0, p1, p2);
      writeTriangleSTL(fileStream, p0, p2, p3);
      numTris += 2;
    }

  // Top Side
  if (!top)
    {
      writeTriangleSTL(fileStream, p4, p5, p6);
      writeTriangleSTL(fileStream, p4, p6, p7);
      numTris += 2;
    }

  // Front side
  if (!front)
    {
      writeTriangleSTL(fileStream, p0, p1, p4);
      writeTriangleSTL(fileStream, p1, p4, p5);
      numTris += 2;
    }

  // Back side
  if (!back)
    {
      writeTriangleSTL(fileStream, p3, p2, p7);
      writeTriangleSTL(fileStream, p2, p7, p6);
      numTris += 2;
    }
}

isNeighborActive ():

Note: cellDim is the number of voxels in each direction for a cell.
gridDim is the number of cells in each direction.

bool isNeighborActive(
    long xCell, long yCell, long zCell, long xVoxel, long yVoxel, long zVoxel)
    const
{
  // Get the "real" coordinates
  if (xVoxel < 0)
    {
      xCell--;
      xVoxel = cellDim.x - 1;
      if (xCell < 0)
        {
          return false;
        }
    }
  else if (xVoxel > (cellDim.x - 1))
    {
      xCell++;
      xVoxel = 0;
      if (xCell > (gridDim.x - 1))
        {
          return false;
        }
    }

  if (yVoxel < 0)
    {
      yCell--;
      yVoxel = cellDim.y - 1;
      if (yCell < 0)
        {
          return false;
        }
    }
  else if (yVoxel > (cellDim.y - 1))
    {
      yCell++;
      yVoxel = 0;
      if (yCell > (gridDim.y - 1))
        {
          return false;
        }
    }

  if (zVoxel < 0)
    {
      zCell--;
      zVoxel = cellDim.z - 1;
      if (zCell < 0)
        {
          return false;
        }
    }
  else if (zVoxel > (cellDim.z - 1))
    {
      zCell++;
      zVoxel = 0;
      if (zCell > (gridDim.z - 1))
        {
          return false;
        }
    }

  const cellVoxelization& cell = modelVoxelization.at(xCell, yCell, zCell);

  if (cell.getSize() == 0)
    {
      return false;
    }

  bool active = cell.at(xVoxel, yVoxel, zVoxel).active;

  return active;
}

I considered using some sort of enumeration for the instructions, but then the ugliness only moves to the next method that has a switch, sadly.

Combinatorics – How many numbers can we choose from $ {1,2, … 2016 } $ so that the sum of four numbers cannot be divided by 11?

How many numbers can we choose? $ {1,2, … 2016 } $ so the sum of four of them cannot be divided by 11

It is not difficult to find some combinations, but the question is how to prove that it is the largest set.

For example, if we choose $ 11N + 1.11N + 4.11N + $ 9 gives 184 * 183 * 183 numbers.

it looks like the evidence will pose an inequality problem. To let $ a_ {i_0}, a_ {i_1} … a_ {i_k}> 0 $ Be the number of numbers we choose from each modulo class that we want to maximize $ a_ {i_0} a_ {i_1} … a_ {i_k} $ However, it is difficult to express the limitation.