1,129 matching pages, found in 378 ms

Ask StyxWritten on your GPU machine; takes a few seconds the first time.

  1. discuss.python.orghttps://discuss.python.org › t › class-variables › 18214
    More about discuss.python.org
    Class variables - Python Help - Discussions on Python.org

    ForumAug 14, 2022. … it goes on to the class, and the superclasses. So looking up instance.attr will also return ‘from the class’. But when we assign to the instance attribute: instance.attr = 'from the instance' now …

    0 points
  2. discuss.python.orghttps://discuss.python.org › t › best-way-to-sort-a-list-into-a… › 24158
    More about discuss.python.org
    Best way to sort a list into a dict based off of an attr on list elements - Python Help - Discussions on Python.org

    ForumFeb 23, 2023. … NoneType'>: [None], <class 'tuple'>: [()], <class 'type'>: [<class 'type'>], <class 'str'>: ['foo']} I think Chris’s answer looks better: from collections import defaultdict result = defaultdict(list) for x in y: result[pred(x)].append …

    0 points
  3. discuss.python.orghttps://discuss.python.org › t › accessing-attributes-of-a-class › 13873
    More about discuss.python.org
    Accessing attributes of a class - Python Help - Discussions on Python.org

    ForumFeb 22, 2022. … if dir() on a class reported the methods and properties that its metaclass defines for the class object in addition to the methods and properties that the class defines for its instances …

    0 points
  4. discuss.python.orghttps://discuss.python.org › t › best-practice-to-do-the-same-t… › 24267
    More about discuss.python.org
    Best practice to do the same tests in pytest with different classes - Python Help - Discussions on Python.org

    ForumFeb 26, 2023. … many tests for a class with a C extension. I redo the same tests for: the c implementation the pure py implementation the subclass of the c implementation the subclass of the …

    0 points
  5. discuss.python.orghttps://discuss.python.org › t › docstrings-threated-differentl… › 7988
    More about discuss.python.org
    Docstrings threated differently for static method and class method - Python Help - Discussions on Python.org

    ForumMar 30, 2021. … help(Foo) I get the docstring of the Callable class for the class method but not the static method? Help on class Foo in module foo: class Foo(builtins.object) | Class methods defined …

    0 points
  6. discuss.python.orghttps://discuss.python.org › t › dataclass-single-reference-to-… › 21205
    More about discuss.python.org
    Dataclass single reference to created field - Python Help - Discussions on Python.org

    ForumNov 18, 2022. … instance of FirstClass shares the same instance of SecondClass The workaround I found was to create a __post_init__() that creates the instance instead @dataclass class FirstClass: # second_class: SecondClass = SecondClass() second …

    0 points
  7. discuss.python.orghttps://discuss.python.org › t › deferred-annotations-and-gener… › 72216
    More about discuss.python.org
    Deferred annotations and generic base classes - Python Help - Discussions on Python.org

    ForumNov 24, 2024. … to pay for using the subscript syntax? The following should definitely be evaluated directly and not deferred, and I suppose the interpreter cannot know the difference? class Bar: ... classes = {"bar": Bar} var …

    0 points
  8. discuss.python.orghttps://discuss.python.org › t › class-composition-between-two-… › 37531
    More about discuss.python.org
    Class Composition Between Two Classes - Python Help - Discussions on Python.org

    ForumOct 31, 2023. … Issue 1 I referenced the tk.Tk class as the ‘master’ class because the code snippet is based on this module. Additionally, in my test snippet: Login - Base class (inheriting from the tk.Tk …

    0 points
  9. discuss.python.orghttps://discuss.python.org › t › add-syntax-for-annotating-a-fu… › 105799
    More about discuss.python.org
    Add syntax for annotating a function/class - Ideas - Discussions on Python.org

    ForumJan 19, 2026. … you're skipping, start from the paragraph above me from typing import Sealed class Node :: Sealed[Leaf, Branch]: ... class Leaf(Node): ... class Branch(Node): ... It’s an actual annotation on the class, not a …

    0 points
  10. discuss.python.orghttps://discuss.python.org › t › 3-12-slot-classes-wishlist › 20742
    More about discuss.python.org
    3.12 slot classes wishlist - Ideas - Discussions on Python.org

    Nov 4, 2022. … Add slotness to a class after the fact. Right now, when creating a slot class, we need to recreate the class from scratch to add slots to it. We’ve tried to make …

    0 points

Search for “The Class site:discuss.python.org” on Google, or add !ddg, !w and other shortcuts to any search.