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
201 questions
Filter by
Sorted by
Tagged with
1vote
1answer
151views

I'm developing a Python interpreter from scratch in C++ as a hobby project to deepen my understanding of the language's internals.I'm currently stuck on implementing the attribute lookup mechanism (...
2votes
3answers
196views

classonlymethod decorator/descriptor defined below is like the built-in classmethod, but you're not allowed to call the method on instances, only on the class itself.from typing import Concatenate, ...
1vote
1answer
77views

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 ...
1vote
0answers
72views

I wrote a simple code where I override the __getattribute__ method so that it always returns an empty string. But Pyright doesn't understand this and complains "int" is not assignable to &...
1vote
1answer
129views

I want to explain to Pyright that my variables in class and instance have different types.I managed to overload __get__ method to achieve this, but now Pyright complains about initialization of ...
2votes
1answer
75views

Passing a class, or a totally different object, as the first argument to method is easy:class Foo: def method(self): ...Foo.method(object()) # pass anything to selfI wonder, is this possible ...
1vote
1answer
85views

Given an object, how can I make a check if it is a method_descriptor?is_method_descriptor = isinstance(obj, method_descriptor) # does not workThe problem: method_descriptor is a builtin but not an ...
1vote
1answer
89views

I want to refactor a big part of my code into a generic descriptor for read only attribute access. The following is an example of property based implementationclass A: def __init__(self, n): ...
1vote
1answer
79views

EDIT This code contains several bugs, see jsbueno's answer below for a correct versionI would like to create read-only attributes that dynamically retrieve values from an internal dictionary. I have ...
1vote
0answers
170views

I'm trying to use type hints in my code but I simply don't understand how the concept applies to a Python descriptor. The only relevant info I could find on the matter was this 6+ year old post but I ...
2votes
3answers
197views

I can't seem to find a definitive answer on the matter and I guess the reason is because it depends on the situation.a, b and c (and d, e, f... as only 3 attributes are listed in this example for ...
0votes
0answers
16views

I want to create a @property like feature with serialization capabilities. It would take some arguments.I have created a descriptor like so:class CustomMethod: def __init__(self, serialize: bool ...
FTG's user avatar
  • 75
0votes
0answers
47views

I'm building my own ORM in Python and ran into an issue. I want to track the access to class variables in order to know which ForeignKey is being used in each part of my code.class IQuery(ABC): &...
0votes
2answers
92views

Here is descriptor class:#descriptorclass Validator: def __set_name__(self,owner,name): self.private_name = '_' + name def __set__(self,obj,value): self.validate(value) ...
1vote
1answer
60views

I would like to be able to decorate instance methods with a class Step such that the methods are replaced by a Step object. At the same time, I'd like to have the option be able to instantiate a step ...

153050per page
1
2345
14

Hot Network Questions

more hot questions
Newest python-descriptors questions feed

[8]ページ先頭

©2009-2025 Movatter.jp