Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
1 answer
228 views

Python3 currency abstract class (without the permission to be instantiated directly)

I'm a newbie python developer who accidentally studied the concept of Abstract classes and I found it pretty much helpful to implement due to the SOLID principles. At the very moment of testing and ...
KhodeNima's user avatar
  • 419
2 votes
1 answer
91 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 ...
SumNeuron's user avatar
  • 291
4 votes
1 answer
168 views

Using composition instead of inheritance and abstract classes

I have a tool that displays data in some format. For example, it can display a list of dogs in a CSV or JSON formats. In the code, I had a lot of places where I had to check the format and display ...
vesii's user avatar
  • 281
4 votes
0 answers
109 views

Inherit docstrings from specified parent

I was recently working on some python where I was working with multiple inheritance and mixins and stuff like that, and I wanted to inherit docstrings for specific functions, from specific parents (...
Andrew's user avatar
  • 61
4 votes
1 answer
133 views

Overriding List subscription to create IndexedHeap for Classical Dijkstra's Algorithm

Much of the academic exposition of Dijkstra's Algorithm (such as Wikipedia, or this class page from Darmouth) relies on your priority queue having the ability decrease the key of an entry: the ...
user513093's user avatar
5 votes
1 answer
345 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 ...
JaDogg's user avatar
  • 4,551
2 votes
0 answers
153 views

Tkinter GUI Python implementation using classes

I'm really struggling to understand application of classes and best practices in fairly advanced level GUIs, and such an example could be extremely helpful. Please note that this is my first GUI ...
Adityendra Suman's user avatar
3 votes
2 answers
87 views

Build object with different input, using super-class and sub-class style, Python 3

I want to model a object of air, the temperature of which can be given in 3 different ways: if the value is known (assuming the temperature is a constant) if a curve of the values with different time ...
aura's user avatar
  • 251
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 ...
Mrityunjay's user avatar
6 votes
2 answers
316 views

(Almost) arbitrary base ints with decorated methods

After reading this question about returning the "next" string in some alphabet (the digits, followed by upper and lowercase ASCII letters) using Java, I thought, well that's just counting, so why not ...
Graipher's user avatar
  • 41.6k
5 votes
1 answer
244 views

Wrapper to translate text in wxPython widgets

I am writing a wrapper for all widgets that contain text that needs to be translated for wxPython and make them handle the initial translation and the change of language on their own using gettext. I ...
Michael K.'s user avatar
5 votes
0 answers
901 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 ...
Noctis Skytower's user avatar
10 votes
1 answer
266 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 ...
Peilonrayz's user avatar
  • 44.3k
14 votes
3 answers
6k views

Create dictionary with default immutable keys

I've created a dictionary subclass with a set of default immutable keys. ...
Seanny123's user avatar
  • 1,617
3 votes
1 answer
898 views

Subclass of socket with optional TLS

...
Torxed's user avatar
  • 133

15 30 50 per page