Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
73 views

I am using vscode for Python dev. I have the Microsoft Extensions (Pylance, Python, Python Debugger, PythonEnviroments) installed and working. The issue is when I try to make a metaclass in vscode ...
Free Man's user avatar
0 votes
1 answer
58 views

I'm trying to wrap my head around the precise order of operations and interactions when a Python class definition involves a metaclass, a init_subclass method, and a class decorator. class Meta(type): ...
user avatar
1 vote
1 answer
59 views

I am writing a Python metaclass that creates a special index of class members that meet certain criteria, one criterion being that those members should not be functions. I am checking this criterion ...
lunaria-bee's user avatar
1 vote
1 answer
76 views

For a project, I want to prevent the use of certain methods in an overriding class. As this happens rather frequently, I am using a metaclass to block many methods at once (how and why is not within ...
502E532E's user avatar
  • 581
0 votes
1 answer
159 views

Description I'm working with LightningDataModule and wanted to ensure that a method (_after_init) runs only once after full initialization, regardless of subclassing. For that, I implemented a custom ...
Aditya Khedekar's user avatar
0 votes
3 answers
118 views

I have a SwiftUI View that I would like to be able to show one of many different other views: struct View1: View { var body: some View { Text("View1") } } struct View2: View ...
CPlus's user avatar
  • 5,110
0 votes
1 answer
99 views

Here is the code: class A: pass class B: pass class Example(A, B): pass ...a lot of method # new class B called BPlus class BPlus: pass # want a new class Example that base on (A, BPlus) but ...
se7enXF's user avatar
  • 144
0 votes
1 answer
184 views

I skimmed over PEP-0589, and I am wondering why typing.TypedDict works when subclassing it like this: class A(TypedDict, total=False): x: int y: int Specifically, TypedDict is a function that ...
Mariy's user avatar
  • 5,964
0 votes
2 answers
67 views

We have some API that should be shut down (e.g. api.shutdown()) just once per python process and specific only to a particular class (e.g. ControllerA) from a hierarchy of controllers (e.g. Controller ...
pevogam's user avatar
  • 628
0 votes
1 answer
41 views

I am trying to write a metaclass to assist in serialization. The intention of the metaclass was to isolate the production code from the serialization mode (e.g. YAML or JSON) as much as possible. So, ...
Steven Dickinson's user avatar
3 votes
1 answer
358 views

I am building an app in PySide6 that will involve dynamic loading of plugins. To facilitate this, I am using ABCMeta to define a custom metaclass for the plugin interface, and I would like this custom ...
KBriggs's user avatar
  • 1,488
1 vote
1 answer
78 views

I've been playing around with Python metaclasses, and I have encountered a rather strange instance where I cannot delete an attribute added to a class object by a metaclass. Consider the following two ...
MrAzzaman's user avatar
  • 4,798
0 votes
1 answer
45 views

i am new in python and having some confusions. As Java, in python also it is showing that Object is the top-most class but then what is the use of Metaclass as it is showing that all classes are ...
subhrajit1891's user avatar
0 votes
1 answer
90 views

I made an abstract base class MyABC, whose metaclass is, of coarse, abc.ABCMeta. Then, I wanted to make a class SubType, whose instances are a subclass of MyABC. Since the instance of it is a class, I ...
Prown's user avatar
  • 15
3 votes
1 answer
29 views

In a UML definition of a metamodel it is possible to define metaconstraints e.g. <<metaconstraint>> umlRole="classifier" <<metaconstraint>> umlRole = "class"...
wikitect's user avatar
  • 474
1 vote
1 answer
82 views

Problem: I am working on a library with, e.g., support for a UInt5 type, an Int33 type, etc. The library is a little more complicated than this, but for the sake of example creating a UInt12 type ...
D. Estes McKnight's user avatar
0 votes
1 answer
83 views

I have some python code: class Meta(type): def __new__(cls, name, base, attrs): attrs.update({'name': '', 'email': ''}) return super().__new__(cls, name, base, attrs) def ...
Pablo Red's user avatar
1 vote
1 answer
76 views

I would like to have a custom metaclass that looks like the definition of a TypedDict. When one declares a new TypedDict we write something like this: from typing import TypedDict class MyClass(...
Nuno's user avatar
  • 245
2 votes
1 answer
336 views

I am trying to modify Enum to return value by default: class EnumDirectValueMeta(EnumMeta): def __getattribute__(cls, name): try: return object.__getattribute__(cls, name)....
mxsx's user avatar
  • 21
1 vote
2 answers
122 views

I have a list of attributes, say ["foo", "bar", "baz"], and I want to write a metaclass which ensures the following properties: They can all be accessed once, in any ...
ijustlovemath's user avatar
0 votes
2 answers
67 views

Is it possible to retain a reference to the parent object when creating an instance of a nested class through the outer object, without explicitly passing the parent object as an argument? class ...
Japan Manul's user avatar
1 vote
1 answer
255 views

Is it possible extend enum during creation? Example: class MyEnum(enum.StrEnum): ID = "id" NAME = "NAME And I need that after creating this enum contains the next fields: ID = &...
Sergey's user avatar
  • 137
0 votes
1 answer
183 views

I create a metaclass and use it in class "Pool", then Vscode will not provide any type hintabout Pool In python i create a metaclass like this: class SignSingleton(type): def __init__(...
AtomOrigin's user avatar
0 votes
1 answer
25 views

When I derive the BaseClass by the ChildClass, the BaseMetaClass.__new__(...) is run twice. First with the keywordarg "foo" and second time with "bar". Is it possible to override &...
Moritz Hartmann's user avatar
0 votes
0 answers
76 views

I always hear or read that 'everything in Python is an object'. This sentence is really helpful for beginner programmers as myself, and I was quickly able to understand that classes, methods are ...
Nuraly's user avatar
  • 25

1
2 3 4 5
25