Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
33 views

Working on LeetCode #1032, I'm having a problem that appears related to having embedded classes. Here is the code: from collections import deque class StreamChecker: def __init__(self, words): ...
Mark Lavin's user avatar
  • 1,272
0 votes
1 answer
64 views

I'm getting the error "AttributeError: 'NoneType' object has no attribute 'name'" for the code below: class Student: def __init__(self, name, house): if not name: ...
Tharindu Dissanayake's user avatar
0 votes
1 answer
710 views

getInitInpArgs on ann gets the input arguments in init of ann to a dictionary. Now I want to define a function like getInitInpArgs on ann (parent class) and not on the child classes, which makes a ...
Farhang Amaji's user avatar
0 votes
1 answer
526 views

I'm quite new to Python, but I understand how cogs work. But what do I have to write in the main-File (to load all the cogs in a subfolder of my main.py) and what do I have to write in the cog? And ...
LukeZ's user avatar
  • 3
0 votes
1 answer
100 views

I am studying python. I'm trying to do a simple exercise from the course I'm studying. I tried to separate the classes into different files to make it easier to keep track of the inheritance and to be ...
Leonardo Rodenas's user avatar
1 vote
0 answers
47 views

class test: def func(self): print(5) class test1: def testing(self, t): t.func = self.another_func def another_func(self): print(6) t = test() t1 = test1() t1.testing(t) # now t....
h8n2's user avatar
  • 699
0 votes
0 answers
5k views

How do I create a one-to-many relationship in a Flask SQLAlchemy database? My db class: class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String, ...
Sharpshooter Gaming's user avatar
0 votes
1 answer
84 views

I have written a class that creates a board for a Klotski game and I want to use breadth-first search to solve the given problem. Here is a bit of my code: EDIT and DISCLAIMER: I added all the ...
NightFox's user avatar
0 votes
1 answer
87 views

I want to add method for one class implemented by C from lru import LRU class A(LRU): def foo(self): print("a") lru is a lib from https://github.com/amitdev/lru-dict error:“...
Cherrymelon's user avatar
0 votes
2 answers
164 views

I had an idea for a simple decorator that would probably not be very useful (feel free to comments on that, but it's not my main focus here). Regardless of that, I think it'd show how to achieve ...
Vedran Šego's user avatar
  • 3,815
2 votes
2 answers
1k views

I am wondering if there is a way to call a method before the object is finally "destroyed" - like some sort of event. I am using a class and a static method. Since it is not an instantiated ...
Niv's user avatar
  • 619
1 vote
2 answers
226 views

I have a class containing tensors that have an unpredictable list of properties. I would like it to generate a list of properties with getters and setter based on a list given at instantiation. Do hou ...
Xiiryo's user avatar
  • 3,287
1 vote
1 answer
74 views

I have a class where the attribute is a numpy array, and a lot of getters, for several slices of that array. The question is about what is a more pythonic way of doing this def get_right_knee(self) -&...
Tlaloc-ES's user avatar
  • 5,344
-2 votes
1 answer
96 views

I am trying to define a function inside of my class but still on line 31 'command=clear' does not see my function i created below. Please help, thank you!! import tkinter as tk from tkinter import * ...
user avatar
0 votes
3 answers
54 views

Good evening! I faced a problem with copy.deepcopy(). I wanted to copy a class which had dict self variable and got this result: >>> import copy >>> class A: ... a = {'a': 1} ... ...
Ivan Nikolsky's user avatar
1 vote
2 answers
127 views

I'm trying to make a class with 2 or more mutually dependent attributes (e.g. a and a-plus-1). The idea is to be able to initialize an object with one and only one of these 2 attributes and the other ...
Xiasu Yang's user avatar
1 vote
3 answers
93 views

I am building a GUI with tkinter where two buttons modify two text fields. One button chooses a random key from the example_dict and displays it in text1 , and the other reveals the corresponding ...
thelmo's user avatar
  • 23
0 votes
2 answers
51 views

I am trying to run a simple budget program and I am a complete beginner with classes in python. I am trying to run everything within the class so I can call back to specific functions. The problem is ...
bread_one2three's user avatar
1 vote
1 answer
461 views

Imagine you have the following code: class A: pass NewA = ... # copy A NewA.__init__ = decorator(A.__init__) # but don't change A's init function, just NewA's I am looking for a way to change ...
Vahid Zee's user avatar
1 vote
1 answer
81 views

How to access self of the decorated method? Based on this answer, the self refer to the decorator: class Decorator: def __init__(self, func): self.func = func def __call__(self, *args,...
Muhammad Yasirroni's user avatar
2 votes
3 answers
691 views

I have a dataclass that looks like this from dataclasses import dataclass, field @dataclass class Data: name: str | None = None file_friendly_name: str | None = field(default=None, init=False)...
codeananda's user avatar
  • 1,448
0 votes
1 answer
712 views

I newly started to develop Django. I want to connect my python algorithm and Django web ui so I tried to connect both of them in views.py but I encountered a problem. It says AttributeError at type ...
samitugal's user avatar
1 vote
1 answer
317 views

I am trying to update a class that is supposed to be used as a custom type for the multiprocessing.manager and imitate a basic dictionary. All works well on Linux, but things fail on Windows and I ...
J.K.'s user avatar
  • 1,635
1 vote
1 answer
131 views

Im making an auth bot, but I faced with a problem! When Im trying to start my selenium bot, it opens few tabs in Chrome and do nothing. It also print that "str" object is not callable Can ...
user avatar
0 votes
0 answers
21 views

So I am following a tutorial and have the following code: import random class Coin: def __init__(self, rare = False, clean = True, heads = True, **kwargs): for key, value in kwargs.items(...
The Koi Fish's user avatar

1
2
3 4 5
11