Movatterモバイル変換


[0]ホーム

URL:


Sorry, we no longer support your browser
Please upgrade toMicrosoft Edge,Google Chrome, orFirefox. Learn more about ourbrowser support.
Skip to main content
Stack Overflow
  1. About
  2. For Teams
Loading…
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives
104 questions
Filter by
Sorted by
Tagged with
4votes
3answers
163views

What happens if __del__ is defined as an async def coroutine in Python (CPython 3.12)?

I'm experimenting with asynchronous patterns in Python and was curious what happens if I define a __del__ method using async def in Python 3.12.For example:class MyClass: async def __del__(self):...
3votes
3answers
283views

Using lru_cache on a class that has a classmethod

I want to cache instances of a class because the constructor is complicated and repeated uses won't alter the contents. This works great. However, I want to create a classmethod to clear the cache. In ...
2votes
1answer
526views

best way to create serializable data model

somewhat inexperienced in python. I am coming from C# world, and I am trying to figure out what is the best practice to create a data structure in python that:can have empty fields (None)can have ...
0votes
1answer
172views

python: create empty dataclass and populate it on demand

python newbie: I need to create an empty data model class, populate it with values and then convert it to JSON string, however i am missing something important here. see error belowmy data class:...
isswf's user avatar
0votes
2answers
96views

Python: Magic method for when the object's reference count changes?

I want to a method that runs when object reference count is changed. is there a method like the following code ?class Foo(): def __method__(self): print("ojbect reference count is ...
TheOnlyWayUp's user avatar
0votes
0answers
114views

Why cls() in a classmethod does not provide argument hints the way that directly calling the class constructor does?

I'm trying to make a subclass with a @classmethod that would take as arguments an instance of its superclass and kwargs for its other fields. The goal is to be able to take an object of the general ...
0votes
0answers
78views

Should I use Model objects from library or make it myself?

I'm working with gitlab webhooks and I need to choose which data model to use in my project.I'm using the Python-gitlab library to work with gitlab, and this library has its own data models for all ...
6votes
2answers
550views

Python dunder methods wrapped as property

I stumbled upon this code that I found weird as it seems to violate the fact that python builtins call dunder methods directly from the class of the object. Using __call__ as an example, if we define ...
0votes
3answers
95views

How to represent the numbers 0 to 3, taking up 2 bits of memory in python

I'm writing code for a Deep Q Network in python. My computer has 32GB of memory but I run into significant issues as the training goes on because the replay buffer maxes out the RAM.I'm looking ...
1vote
1answer
58views

classmethods and data model methods, implementing operands over classes or types

Here is what you would expect if you try and use the add operand over a type and int or between two type objects.>>> class Foo:... pass...>>> class Bar:... pass...>&...
ekiim's user avatar
0votes
1answer
427views

Are there any unique features provided only by metaclasses in Python?

I have read answers for this question: What are metaclasses in Python? and this question: In Python, when should I use a meta class? and skimmed through documentation: Data model.It is very possible ...
alex_why's user avatar
3votes
2answers
2kviews

Wrapping derived class method from base class

Imagine I have a base and a derived class like so:class A: def foo(self): passclass B(A): def foo(self): passI wish to wrap calls foo calls made by instances of B. ...
2votes
1answer
497views

How can I access the weakref object of the class itself through the class?

As far as I know, __weakref__ is a descriptor defined in class, so that if it invoked from the instances of the class, it will give the weakref object:from weakref import refclass A: passobj =...
11votes
1answer
3kviews

Where is the default behavior for object equality (`==`) defined?

According to the object.__eq__() documentation, the default (that is, in the object class) implementation for == is as follows:True if x is y else NotImplementedStill following the documentation ...
0votes
1answer
530views

Usage of __setattr__ to rewrite whole method of library class issue: missing 1 required positional argument: 'self'

I've got some imported packages with tricky structureand need to call some method that bases on lots of other methodswith non-default parameters, which are not class attributes themself like ...
MosQuan's user avatar

153050per page
1
2345
7

Hot Network Questions

more hot questions
Newest python-datamodel questions feed

[8]ページ先頭

©2009-2025 Movatter.jp