All Questions
8 questions
1
vote
1
answer
72
views
Python 3.10+: an exploration of meta classes and subclasses through the lens of metric (SI) prefixes with subclass-able units and changeable bases
Problem Statement
From the National Institute of Standards and Technology's Office of Weights and Measures, one can find a handy list of all the metric prefixes:
e.g.
Purpose
Name
Symbol
Factor
Name
...
5
votes
1
answer
336
views
List subclasses of a class
Description
Given a class, return all its subclasses (recursively).
As you can see I've eliminated recursion using a stack.
What I want reviewed
Is there a better way to do this?
How can I make this ...
1
vote
1
answer
4k
views
Write a class for Team which should have function to prints players details
I have written it using aggregation but i feel its not the best way we can do this. Please suggest is there any other way to do this. I think we can also built this without using player class, just ...
5
votes
0
answers
894
views
Writing a metaclass to ensure a class is thread-safe
Python allows the creation of classes to be modified via metaclasses. They can perform all sorts of operations that might appear to be magical to languages that do not have the capability. The goal of ...
1
vote
0
answers
1k
views
Marking a class as final or sealing a class
Which of these metaclasses should be preferred, and is there room for improvement?
Some people are not familiar with the philosophies that come with working in Python and have a desire embedded in ...
10
votes
1
answer
255
views
Implementing a Maybe for multidimensional data
The scenario is we're working with a REST endpoint that gives us nice JSON objects. We're using requests, and everything works wonderfully. But one day you notice that data you though was always being ...
4
votes
2
answers
9k
views
Structure of inheritance between Animal classes and methods
I'm trying to do some basic inheritance between the 3 classes and use some simple methods, and I'm looking to learn what should be the correct structure between them and what can be improved.
...
4
votes
1
answer
234
views
Creating a game with rectangular shapes
I'm using Pygame to create a small game with few rectangle shapes. However, I want to learn more about classes, and I'm trying to use them. I'm very new to classes and inheritance, but I want to ...