Tag: python

57 votes
6 answers
2.3K views
How is set() implemented?

I've seen people say that set objects in python have O(1) membership-checking. How are they implemented i

avatar
Dusty
0 1 0 9
asked 07 September, 2021
51 votes
21 answers
1K views
What is the best way to implement nested dictionaries?

I have a data structure which essentially amounts to a nested dictionary. Let's say it looks like this:

avatar
Boyd
0 1 0 9
asked 07 September, 2021
57 votes
10 answers
1.9K views
Python Sets vs Lists

In Python, which data structure is more efficient/speedy? Assuming that order is not important to me and I wou

avatar
Trudy
0 1 0 9
asked 07 September, 2021
56 votes
16 answers
1.7K views
How can I implement a tree in Python?

I am trying to construct a General tree. Are there any built-in data structures in Python to implement it?

avatar
Bryan
0 1 0 9
asked 07 September, 2021
59 votes
17 answers
374 views
What do I use for a max-heap implementation in Python?

Python includes the heapq module for min-heaps, but I need a max heap. What should I use for a max-heap imple

avatar
Suzan
0 1 0 9
asked 07 September, 2021
65 votes
12 answers
1.3K views
In Python, when to use a Dictionary, List or Set?

When should I use a dictionary, list or set? Are there scenarios that are more suited for each data type?

avatar
Ali
0 1 0 9
asked 07 September, 2021
60 votes
3 answers
459 views
How are Python's Built In Dictionaries Implemented?

Does anyone know how the built in dictionary type for python is implemented? My understanding is that it is s

avatar
Juliane
0 1 0 9
asked 07 September, 2021
63 votes
13 answers
2.8K views
How can I remove a key from a Python dictionary?

When deleting a key from a dictionary, I use: if 'key' in my_dict: del my_dict['key']

avatar
Jeff
0 1 0 9
asked 07 September, 2021
60 votes
18 answers
1K views
How do I sort a list of dictionaries by a value of the dictionary?

I have a list of dictionaries and want each item to be sorted by a specific value. Take into consideration the

avatar
Nereida
0 1 0 9
asked 07 September, 2021
60 votes
2 answers
2.4K views
How to obtain values of parameters of get request in flask?

The answer that I found on the web is to use request.args.get. However, I cannot manage it to work. I have the

avatar
Serina
0 1 0 9
asked 07 September, 2021
54 votes
7 answers
2.4K views
Problem HTTP error 403 in Python 3 Web Scraping

I was trying to scrape a website for practice, but I kept on getting the HTTP Error 403 (does it think I'

avatar
Venice
0 1 0 9
asked 07 September, 2021
64 votes
11 answers
2.4K views
Auto reloading python Flask app upon code changes

I'm investigating how to develop a decent web app with Python. Since I don't want some high-order st

avatar
Roger
0 1 0 9
asked 07 September, 2021