Skip to main content
5 votes
1 answer
108 views

Consider the following snippet: from collections import UserDict class D(dict): ... d = D(foo="bar", baz=42) print(d.popitem()) # ('baz', 42) class UD(UserDict): ... ud = UD(foo="...
maejam's user avatar
  • 53
1 vote
1 answer
152 views

I want to build a function that can look at the raw material on hand information I provide, then come up with combinations of inputs to achieve a desired number of finished products. on_hand_inventory ...
LT_AKR's user avatar
  • 81
-1 votes
1 answer
133 views

How does a minimal implementation of a Sequence from collections.abc, together with the correct type hints, look like? According to its documentation, __len__ and __getitem__ are sufficient. My type ...
502E532E's user avatar
  • 611
0 votes
1 answer
122 views

I need to zip iterables with a personal mask function or just mask lists [True, False, ...] from collections.abc import Callable def zip_mask(a, b, mask): iter_a, iter_b = iter(a), iter(b) if ...
king Carrey's user avatar
2 votes
1 answer
656 views

I am using Python 3.11.5 with the below code: import asyncio from collections.abc import AsyncIterable # Leave this iterable be, the question is about # how to use many instances of this in parallel ...
Intrastellar Explorer's user avatar
0 votes
2 answers
2k views

I have trying to fix an import error with the requests library in Python 3.11. This is to run a Discord bot that I have created. My original error is given as ImportError: cannot import name 'Mapping' ...
AJMullen's user avatar
0 votes
1 answer
1k views

I am doing the Leetcode valid parenthesis question and want to implement the ans using deque stack. there are three types of parenthesis {[()]} and i need to check the top of the stack before i pop it....
 Prathamesh Padhye's user avatar
0 votes
0 answers
147 views

I've written a python code to check the unique values of the specified column names from a pandas dataframe. Main Code: Checking the unique values & the frequency of their occurence def uniq_fun(...
Apoorva's user avatar
  • 115
0 votes
1 answer
160 views

I am trying to define a class that is supposed to simultaneously do two things: serve as the metaclass for a dataclass act like a mapping i.e., it will need to be derived from both type and typing....
joxirerehufe's user avatar
2 votes
1 answer
75 views

I know similar questions have been asked before but I cannot find an adequate answer to my situation. Let's say I have the following list of tuples: d = [('first', 1), ('second', 2), ('third', 3)] I ...
besi's user avatar
  • 171
0 votes
1 answer
100 views

I have list of tuples in the following format, [('ABC', ['32064', ['WOO', 'MISSI']]), ('XYZ', ['32065', ['HAY']])] I need to convert them into following format, [['ABC','32064','Woo'], ['ABC','32064',...
code_bug's user avatar
  • 425
-1 votes
2 answers
198 views

I'm looking for a way to maintain and update a list of IP addresses that I can index into (via a pair of IP addresses) to add a new address to the list. For example, suppose I have an arbitrary index ...
wwwalker's user avatar
1 vote
1 answer
581 views

This is the question: and this the output that is required: This is code I have written so far: class_list = [] keys = [] meanings = [] def script(): key = input("Enter the word: ") ...
carlos's user avatar
  • 45
1 vote
1 answer
318 views

Python's dict.pop(key[, default]) ignores the default value set by collections.defaultdict(default_factory) as shown by the following code snippet: from collections import defaultdict d = defaultdict(...
joseville's user avatar
  • 1,033
-5 votes
1 answer
49 views

I'm trying to sort my confusions learning python. >>> cities = ['London', "Toronto", 'Paris', 'Oslo'] >>> cities ['London', 'Toronto', 'Paris', 'Oslo'] >>> for i ...
Master_Roshy's user avatar
  • 1,275

15 30 50 per page
1
2 3 4 5
9