QuestionId int64 74.8M 79.8M | UserId int64 56 29.4M | QuestionTitle stringlengths 15 150 | QuestionBody stringlengths 40 40.3k | Tags stringlengths 8 101 | CreationDate stringdate 2022-12-10 09:42:47 2025-11-01 19:08:18 | AnswerCount int64 0 44 | UserExpertiseLevel int64 301 888k | UserDisplayName stringlengths 3 30 ⌀ |
|---|---|---|---|---|---|---|---|---|
78,215,638 | 591,064 | Environment variable PATH_INFO not defined by lighttpd using uwsgi module | <p>I have lighttpd version 1.4.73 running on Alpine Linux. I enabled <code>mod_scgi</code> and added this to my configuration file:</p>
<pre><code>scgi.protocol = "uwsgi"
scgi.server = (
"/tp2/" => ( "tp2-app" => (
"host" => "127.0.0.1",
... | <python><uwsgi><bottle><lighttpd> | 2024-03-24 18:27:12 | 1 | 10,249 | ixe013 |
78,215,448 | 2,221,360 | Assigning values to numpy array based on multiple conditions of multiple array | <p>I have the ocean and atmospheric dataset in netcdf file. Ocean data will contain <code>nan</code> or any other value <code>-999</code> over land area. For this eample, say it is <code>nan</code>. Sample data will look like this:-</p>
<pre><code>import numpy as np
ocean = np.array([[2, 4, 5], [6, np.nan, 2], [9, 3, n... | <python><numpy><netcdf> | 2024-03-24 17:20:27 | 2 | 3,910 | sundar_ima |
78,215,423 | 2,016,632 | Why does gcloud build insist on making new PIP packages each time? | <p>I have <code>Google Cloud SDK 469.0.0, alpha 2024.03.15, beta 2024.03.15, bq 2.1.1, core 2024.03.15, gsutil 5.27</code></p>
<p>I read on multiple Stackoverflow posts that if I structure my Dockerfile as</p>
<pre><code>FROM python:3.12
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY requirements.txt ./
RUN pip install -r .... | <python><docker><google-cloud-platform> | 2024-03-24 17:15:25 | 1 | 619 | Tunneller |
78,215,364 | 344,286 | How can I convert a Python multithreaded socket client/server to asyncio? | <p>I'm writing a tool to test an asyncio based server end-to-end. Initially I was going to spin up the server in one terminal window, and run the test in a separate window, but then I realized that it should be possible to just do that in one script. After all, I can do it with a <code>concurrent.futures.ThreadPoolExec... | <python><multithreading><async-await><python-asyncio> | 2024-03-24 17:00:33 | 4 | 52,263 | Wayne Werner |
78,215,347 | 7,644,562 | Load EMNIST dataset from within the Pytorch | <p>I'm working on <strong>EMNIST</strong> dataset and want to load it from PyTorch, but it returns a strange error as:</p>
<blockquote>
<p>RuntimeError: File not found or corrupted.</p>
</blockquote>
<p>Here's how i have tried to load the dataset:</p>
<pre><code>trainset = torchvision.datasets.EMNIST(root="emnist&... | <python><machine-learning><deep-learning><pytorch><mnist> | 2024-03-24 16:53:53 | 2 | 5,704 | Abdul Rehman |
78,215,243 | 12,193,952 | Python app keeps OOM crashing on Pandas merge | <p>I have a ligh Python app which should perform a very simple task, but keeps crashing due to OOM.</p>
<h2>What app should do</h2>
<ol>
<li>Loads data from <code>.parquet</code> in to dataframe</li>
<li>Calculate indicator using <code>stockstats</code> package</li>
<li>Merge freshly calculated data into original dataf... | <python><python-3.x><pandas><docker><out-of-memory> | 2024-03-24 16:22:02 | 2 | 873 | FN_ |
78,215,217 | 2,835,670 | Getting the plot points for a kernel density estimate in seaborn | <p>I am using this code</p>
<pre><code>kde = sns.kdeplot(x = data, fill = True, color = "black", alpha = 0.1)
</code></pre>
<p>to get the kde for my data, and it works well. I am now trying to get all the x,y - point used to draw the plot and I am doing:</p>
<pre><code>poly = kde.collections[0]
x_values = pol... | <python><seaborn><kernel-density> | 2024-03-24 16:11:37 | 1 | 2,111 | user |
78,215,203 | 18,756,733 | Image channel error while training CNN model | <p>I get the following error when trying to train a CNN model:</p>
<pre class="lang-none prettyprint-override"><code>InvalidArgumentError: Graph execution error:
Detected at node decode_image/DecodeImage defined at (most recent call last):
<stack traces unavailable>
Number of channels inherent in the image must ... | <python><tensorflow><keras><deep-learning><conv-neural-network> | 2024-03-24 16:07:28 | 1 | 426 | beridzeg45 |
78,215,201 | 1,694,745 | Decrypt ruby DES-EDE3-CBC encrypted data in Python | <p>I have a bunch of data which are encrypted in Ruby by following code</p>
<pre><code>text = '12345678'
key = '6b4f0a29d4bba86add88be9d'
cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt
cipher.key = key
s = cipher.update(text) + cipher.final
encrypted_text = s.unpack('H*')[0].upcase
# => 3B223AA60F1921F34CBBBAC... | <python><ruby><encryption><openssl> | 2024-03-24 16:07:24 | 1 | 1,068 | Tiktac |
78,215,187 | 4,387,837 | sklearn ComplementNB: only class 0 predictions for perfectly seperable data | <p>As shown below, the balanced, one dimensional data below can be perfectly separated by <code>sklearn GaussianNB</code>. Why is it that <code>sklearn ComplementNB</code> gives classifications that are all zeros for the same data?</p>
<pre><code>from sklearn.naive_bayes import GaussianNB
from sklearn.naive_bayes impor... | <python><scikit-learn><classification><naivebayes> | 2024-03-24 16:04:28 | 1 | 839 | HOSS_JFL |
78,215,078 | 7,846,884 | broadcasting tensor matmul over batches | <p>how can i find dot product of each batch response and X data.</p>
<pre><code>y_yhat_allBatches_matmulX_allBatches = torch.matmul(yTrue_yHat_allBatches_tensorSub, interceptXY_data_allBatches[:, :, :-1])
</code></pre>
<p>expected shape of <code>y_yhat_allBatches_matmulX_allBatches</code> should be 2 by 5. where each r... | <python><tensorflow><pytorch><array-broadcasting> | 2024-03-24 15:26:11 | 1 | 473 | sahuno |
78,215,046 | 5,795,116 | Slow Scraping Using Selenium | <p><a href="https://i.sstatic.net/fndvb.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fndvb.png" alt="enter image description here" /></a>I am trying to scrape website using selenium.But it is very slow.Taking a minute for every record.</p>
<p>The webpage is <a href="https://jamabandi.nic.in/land%20rec... | <python><selenium-webdriver><web-scraping> | 2024-03-24 15:17:12 | 1 | 327 | jatin rajani |
78,215,019 | 11,748,924 | np.save and np.load with memmap mode returned OSError | <p>I tried this simple code:</p>
<pre><code>import numpy as np
np.save('tmp.npy', np.empty(128))
tmp = np.load('tmp.npy', mmap_mode='r+')
np.save('tmp.npy', tmp[:64])
</code></pre>
<p>It returned <code>OSError</code>:</p>
<pre><code>---------------------------------------------------------------------------
OSError ... | <python><numpy><numpy-memmap> | 2024-03-24 15:09:31 | 0 | 1,252 | Muhammad Ikhwan Perwira |
78,214,916 | 2,303,071 | How to parse subdomains from URLs in FastAPI? | <p>Our customers are going to hit our new API at <code>foo123.bar456.domain.com/v1.5/</code></p>
<p>The <code>foo123</code> and <code>bar456</code> subdomains are account-specific (and let us load balance). They signify relationships and trigger processing we need to do.</p>
<p>We don't want to (repetitively) pass que... | <python><fastapi><subdomain><starlette><parse-url> | 2024-03-24 14:38:44 | 1 | 1,093 | Todd Curry |
78,214,680 | 8,849,755 | Skip with statement in Python if condition is met | <p>Consider the following code:</p>
<pre class="lang-py prettyprint-override"><code>if not condition:
with my_object.whatever(...) as context_manager:
do_something()
</code></pre>
<p>Is it possible to put the checking of <code>condition</code> inside <code>my_object.whatever</code> such that I don't need to... | <python><with-statement> | 2024-03-24 13:25:35 | 0 | 3,245 | user171780 |
78,214,609 | 726,730 | Restarting process raises runtimeerror (can't create new thread at interpreter shutdown) | <p>I have two processes: P1 and P2. P1 send data to P2 (with shared memory).</p>
<p>When something goes wrong to P2 a PyQt5 Window with the error message is opened.
One option in the window is to restart process P2 by terminated and re-instantiating.</p>
<p>After this operation the P1 process resend data to P2.</p>
<p>... | <python><multiprocessing><python-multiprocessing> | 2024-03-24 13:06:11 | 0 | 2,427 | Chris P |
78,214,561 | 9,720,161 | Stable-Baslines3 Type Error in _predict w. custom environment & policy | <p>I'm in the process of integrating a custom environment and policy into Stable-Baselines3 (SB3). While setting up the <code>_predict</code> functionality, I encountered an issue. Although I can manually utilize the <code>_predict</code> functionality with a standard Python <code>dict</code>. I need to define the envi... | <python><reinforcement-learning><openai-gym><stable-baselines> | 2024-03-24 12:50:51 | 0 | 303 | AliG |
78,214,529 | 984,621 | Scrapy - how do I load data from the database in ItemLoader before sending it to the pipeline? | <p>I have a PSQL database table <code>brands</code> where are columns like <code>id</code>, <code>name</code>, and other columns.</p>
<p>My (simplified) code - <code>MySpider.py</code>:</p>
<pre><code>import DB
class MySpider(scrapy.Spider):
db = DB.connect()
def start_requests(self):
urls = [ 'https://www.web... | <python><scrapy> | 2024-03-24 12:44:34 | 0 | 48,763 | user984621 |
78,214,361 | 386,861 | How to handle inf and nans in Great Table | <p>I've got a dataframe that I want to format which includes inf and nan.</p>
<p>The dict for it is:</p>
<pre><code>df = pd.DataFrame({'Foodbank': {0: 'study',
1: 'generation',
2: 'near',
3: 'sell',
4: 'former',
5: 'line',
6: 'ok',
7: 'field',
8: 'last',
9: 'really',
10: 'particularly',
11: 'must'... | <python><pandas><great-tables> | 2024-03-24 11:36:17 | 1 | 7,882 | elksie5000 |
78,214,089 | 1,001,889 | MyPy and sqlalchemy - "Session" has no attribute "__enter__"; maybe "__iter__"? Mypyattr-defined | <p>I recently updated mypy configuration for my python 3.11 project, adding an .ini file to check my already working sql alchemy code. <strong>I'm using sqlalchemy == 2.0.29</strong></p>
<p>It oddly started complaining about this line of code:</p>
<p><a href="https://i.sstatic.net/u80Z2.png" rel="nofollow noreferrer"><... | <python><sqlalchemy><mypy> | 2024-03-24 10:06:15 | 0 | 3,818 | Shine |
78,213,951 | 1,082,349 | Why does scipy.sparse.linalg.spsolve crash when numpy.linalg.solve does not? | <p>I have a sparse Matrix <code>B</code> and an array <code>b</code> (uploaded <a href="https://file.io/QOrK3j5inVW8" rel="nofollow noreferrer">here</a>), and am trying to do</p>
<pre><code>import numpy as np
import config
from scipy.sparse.linalg import spsolve
from scipy.sparse import load_npz
from numpy.linalg impor... | <python><numpy><scipy> | 2024-03-24 09:10:59 | 0 | 16,698 | FooBar |
78,213,865 | 774,133 | Group dataframe by some columns, do nothing, display result | <p>I have a Pandas dataframe and need to group its values by some columns, then do nothing, finally show the resulting dataframe. This might appear as a strange operation, but it is only for visualisation purposes as I need to format the dataframe in a Latex tabular environment.</p>
<p>Consider this example:</p>
<pre ... | <python><pandas> | 2024-03-24 08:33:55 | 1 | 3,234 | Antonio Sesto |
78,213,800 | 826,112 | Why is my sieve of sundaram so inefficient | <p>I have been playing around with prime sieves and their performance. I've turned to the Sundaram sieve. My implementation is:</p>
<pre><code>import time
from pympler import asizeof
start = time.perf_counter()
limit = 10000
upper = int(limit/2)
numbers = [i for i in range(upper)]
for j in range(1,int(upper/2)):
... | <python> | 2024-03-24 08:04:26 | 1 | 536 | Andrew H |
78,213,588 | 19,146,511 | usage of vllm for extracting embeddings | <p>Following is a little piece of code to extract embeddings from a certain layer of LLM:</p>
<pre class="lang-py prettyprint-override"><code>def process_row(prompt: str, model, tokenizer, layers_to_use: list, remove_period: bool):
"""
Processes a row of data and returns the embeddings.
"... | <python><nlp><huggingface-transformers><large-language-model> | 2024-03-24 06:30:06 | 0 | 307 | lazytux |
78,213,511 | 4,170,439 | Remove (not clear) attachments from email | <p>Python 3.6</p>
<p>I'm trying to archive some old mails, and I want to remove attachments from some of them.</p>
<p>However, if I use the <code>clear()</code> method, the MIME part remains in the mail, just empty (so it's assumed to be of type <code>text/plain</code>). I came up with a really hacky solution of conver... | <python><email><mime> | 2024-03-24 05:35:17 | 1 | 329 | Bangaio |
78,213,463 | 3,358,488 | Running ChatGPT programmatically - How to continue conversation without re-submitting all past messages? | <p>One can obtain a ChatGPT response to a prompt using the following example:</p>
<pre class="lang-py prettyprint-override"><code>from openai import OpenAI
client = OpenAI() # requires key in OPEN_AI_KEY environment variable
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[... | <python><openai-api><langchain><chatgpt-api> | 2024-03-24 05:11:31 | 1 | 5,872 | user118967 |
78,213,351 | 2,328,154 | ALLOW_ADMIN_USER_PASSWORD_AUTH not getting set in AWS CDK | <p>I am trying to set the Authentication Flows in my Cognito - User Pool - App Client to the flows below in AWS CDK.</p>
<ul>
<li>ALLOW_ADMIN_USER_PASSWORD_AUTH</li>
<li>ALLOW_CUSTOM_AUTH</li>
<li>ALLOW_REFRESH_TOKEN_AUTH</li>
<li>ALLOW_USER_SRP_AUTH</li>
</ul>
<p>I can only get it to add these flows.</p>
<ul>
<li>ALLO... | <python><amazon-cognito><aws-cdk> | 2024-03-24 04:04:18 | 1 | 421 | MountainBiker |
78,213,135 | 16,614,515 | How do I update the matplotlib elements of a sympy plot? | <p>This following code below consists of a matplotlib graph of the function y > 5/x, with the ability to fill in the graph as the user pans/zooms outward.</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
x_range = np.linspace(-10, 10, 400)
y_range = 5 / x_range
line, = ax... | <python><python-3.x><matplotlib><charts><sympy> | 2024-03-24 01:41:32 | 1 | 316 | LuckElixir |
78,213,102 | 543,572 | How to add class variable values to a list, python 3x? | <p>I'm trying to add class variable values to a list inside a function, but I'm not seeing any errors or the expected output? The comboxbox doesn't display when I uncomment the list code.</p>
<p>Outside of the function, this code works standalone:</p>
<pre><code>value_list = []
selected_float = 0.5
value_list.append(s... | <python><ttk><python-class><ttkbootstrap><ttkcombobox> | 2024-03-24 01:20:35 | 1 | 15,801 | James-Jesse Drinkard |
78,212,699 | 6,546,694 | How to use featuretools at the test time? | <p>I would demonstrate the issue with an example:</p>
<p>Let us say we want to use the primitive 'PERCENTILE'</p>
<p>Imports:</p>
<pre><code>import pandas as pd
import featuretools as ft
</code></pre>
<p>For training (create a simple data with one column and let featuretools compute a percentile feature on top of it):<... | <python><pandas><featuretools> | 2024-03-23 22:17:32 | 0 | 5,871 | figs_and_nuts |
78,212,679 | 11,748,924 | Numpy memmap still using RAM instead of disk while doing vector operation | <p>I initialize two operands and one result:</p>
<pre><code>a = np.memmap('a.mem', mode='w+', dtype=np.int64, shape=(2*1024*1024*1024))
b = np.memmap('b.mem', mode='w+', dtype=np.int64, shape=(2*1024*1024*1024))
result = np.memmap('result.mem', mode='w+', dtype=np.int64, shape=(2*1024*1024*1024))
</code></pre>
<p>At id... | <python><numpy><memory><memory-management><numpy-memmap> | 2024-03-23 22:10:31 | 1 | 1,252 | Muhammad Ikhwan Perwira |
78,212,325 | 16,845 | Type annotations for a dictionary that maps types to a list of instances of that type? | <p>In Python 3.11, I would like to create a class that holds a dictionary where the key is the type of a class and the value of that key is a list of objects of that type. The code:</p>
<pre><code>import typing
T = typing.TypeVar("T")
class DictHolder:
def __init__(self):
self._things: dict[type[T], l... | <python><python-3.x><dictionary> | 2024-03-23 20:14:34 | 2 | 1,216 | Charles Nicholson |
78,212,322 | 7,211,014 | Flask how can I use after_request to print out all responses and not break swagger-ui? | <p>Setup:</p>
<ul>
<li>connexion[swagger-ui]==2.13.0</li>
<li>Flask==2.2.5</li>
</ul>
<p>I am using connexion (Not Flask directly), to set up my app and host swagger. I want to print out every request and response payload to console before sending it.</p>
<p>I tried using these after building my connexion app</p>
<pre>... | <python><flask><swagger><response><connexion> | 2024-03-23 20:13:56 | 1 | 1,338 | Dave |
78,212,315 | 471,478 | Is there a sum(min_count=1) that is as fast as sum on DataFrameGroupBy.agg | <p>I have a DataFrame with a few million rows that I groupby and sum various columns via</p>
<pre><code>df.groupby(…).agg({
"foo": "sum",
"bar": "sum",
…})
</code></pre>
<p>That is rather fast and takes around 10 seconds on my machine.</p>
<p>Now I need a variant of sum tha... | <python><python-3.x><pandas> | 2024-03-23 20:10:51 | 3 | 12,364 | scravy |
78,212,299 | 1,169,091 | How to use a specific column on the X-axis of a DataFrame plot | <p>I want my plot to use State names on the x-axis, not the index values.
This code produces the graph:</p>
<pre><code>print(df.info())
print(df)
df.plot(kind='bar')
plt.xlabel('State')
plt.ylabel('Total Sales')
plt.title('Total Sales by State')
plt.show()
</code></pre>
<p>This is the output:</p>
<pre><code><class '... | <python><pandas><matplotlib><plot> | 2024-03-23 20:06:16 | 1 | 4,741 | nicomp |
78,212,127 | 9,720,964 | Python datetime.replace() has unexpected behaviour when uploading to Firebase Firestore | <p>For testing purposes, I have deployed the following Firebase Cloud Function. When the function gets called, it adds a document to my Firestore collection with two fields containing two datetimes.</p>
<pre class="lang-py prettyprint-override"><code>@https_fn.on_call(region='europe-west1', vpc_connector='connector1', ... | <python><firebase><google-cloud-firestore><google-cloud-functions><python-datetime> | 2024-03-23 19:13:00 | 1 | 447 | jaakdentrekhaak |
78,211,958 | 3,305,998 | How can I test rust functions wrapped by pyo3 in rust, before building and installing in python? | <p>I have functionality written in rust, which I am exposing to python via pyo3. I would like to test that the python functions are correctly exposed and handle python types correctly.</p>
<p>I already have tests in place to validate the actual functional implementation (in rust) and the end-to-end integration (in pyth... | <python><unit-testing><rust><pyo3> | 2024-03-23 18:14:32 | 1 | 318 | MusicalNinja |
78,211,910 | 4,089,351 | Is the error 'name 'Scene' is not defined' in Maning a generic output, or does it have a concrete meaning, and how to fix it? | <p>Running on Windows VSC the following code from the <a href="https://3b1b.github.io/manim/getting_started/example_scenes.html" rel="nofollow noreferrer">Manim examples</a>:</p>
<pre><code>from manim import *
class OpeningManimExample(Scene):
def construct(self):
intro_words = Text("""
... | <python><manim> | 2024-03-23 18:01:16 | 0 | 4,851 | Antoni Parellada |
78,211,842 | 2,862,945 | Getting interpolation out of nested for loops in python | <p>I have a 2D structure with a certain shape in the (xz) plane. For simplicity, I set it here to be of circular shape. I basically need to rotate that structure around the z axis and my idea was to do that with an interpolation function. <code>RegularGridInterpolator</code> (<a href="https://docs.scipy.org/doc/scipy/r... | <python><for-loop><optimization><scipy><interpolation> | 2024-03-23 17:39:29 | 1 | 2,029 | Alf |
78,211,526 | 8,405,296 | PyTorch: AttributeError: 'torch.dtype' object has no attribute 'itemsize' | <p>I am trying to follow this article on medium <a href="https://dassum.medium.com/fine-tune-large-language-model-llm-on-a-custom-dataset-with-qlora-fb60abdeba07" rel="nofollow noreferrer">Article</a>.</p>
<p>I had a few problems with it so the remain chang eI did was to the <code>TrainingArguments</code> object I adde... | <python><pytorch><databricks><huggingface><peft> | 2024-03-23 16:05:27 | 5 | 1,362 | Lidor Eliyahu Shelef |
78,211,442 | 10,531,186 | When using a jupyter notebook in VSCode, the Python interpreter is ignored | <p>I have a virtual environment with some installed packages and a notebook with some imports of packages that only exist in this environment.</p>
<p>I have done Ctrl + Shift + P > Python: Select Interpreter, and chosen my environment.</p>
<p>But, if I run the cell, it tells me ModuleNotFoundError, as it tries to us... | <python><visual-studio-code><jupyter-notebook><jupyter><interpreter> | 2024-03-23 15:37:12 | 2 | 324 | someguy |
78,211,423 | 1,136,300 | dask dataframe aggregation without groupby (ddf.agg(['min','max'])? | <p>Pandas define dataframe.agg, but DASK only defines dask_dataframe.groupby.agg.</p>
<p>Is there a way to have multiple aggregations over a column in dask without groupby?</p>
<p>I know describe() has columns statistics, which solves <strong>one</strong> specific problem, but I'm looking for a general solution.</p>
<p... | <python><pandas><dask><dask-dataframe> | 2024-03-23 15:30:08 | 1 | 683 | Carlos Troncoso |
78,211,422 | 9,142,615 | Why does my ffmpeg command fails from python subprocess? | <p>I want to concat two movies with ffmpeg. In the shell I can execute this:
<code>\\programs\2d\ffmpeg\inst\ffmpeg.bat -y -i "concat:C:/daten/movieA.ts1|C:/daten/movieB.ts2" -c copy -bsf:a aac_adtstoasc C:/daten/movieConcat.mov</code> and it works fine. If I try to call it from a python subprocess:</p>
<pre>... | <python><ffmpeg> | 2024-03-23 15:29:31 | 1 | 1,978 | haggi krey |
78,211,399 | 3,305,998 | How can I separate a rust library and the pyo3 exported python extensions which wrap it | <p>I have a rust library which provides useful functionality for use in other rust programs. Additionally I would like to provide this functionality as a python extension (using pyo3 and setuptools-rust, although most of this is tool agnostic)</p>
<p>The documentation examples all show a single library. This means that... | <python><rust><pyo3> | 2024-03-23 15:21:21 | 1 | 318 | MusicalNinja |
78,211,377 | 22,213,065 | Script not list excel search result for me | <p>I wrote a python script that must search for <code>Mar</code> <code>Jun</code> <code>Sep</code> <code>Dec</code> in my xlsx file and provide name of search result columns in text file to me.</p>
<pre><code>import pandas as pd
# Path to the Excel file
excel_file = r'E:\Desktop\Big_comp_cap\New Microsoft Excel Worksh... | <python><pandas><excel><xlsx> | 2024-03-23 15:12:14 | 0 | 781 | Pubg Mobile |
78,211,255 | 11,110,455 | How to low stdout verbosity for AppDynamics Agent and Proxy in Python Applications | <p>I'm integrating the AppDynamics Python Agent into a FastAPI project for monitoring purposes and have encountered a bit of a snag regarding log verbosity in my stdout. I'm launching my FastAPI app with the following command to include the AppDynamics agent:</p>
<pre class="lang-bash prettyprint-override"><code>pyagen... | <python><logging><proxy><appdynamics> | 2024-03-23 14:30:22 | 1 | 1,813 | Felipe Windmoller |
78,211,236 | 6,618,225 | Creating a WHILE-Loop with a dynamic number of conditions in Python | <p>I am looking for a solution to create a dynamic WHILE Loop. For example, if I have a game with a flexible number of players (2-6) and each player has a score, the WHILE Loop should end when one of those players reached a score of 100. I had the idea to create a nested list where every list item is another list that ... | <python><python-3.x><while-loop> | 2024-03-23 14:25:41 | 1 | 357 | Kai |
78,211,119 | 3,015,186 | How to tackle "Statement is unreachable [unreachable]" with mypy when setting attribute value in a method? | <h3>Problem description</h3>
<p>Suppose a following test</p>
<pre class="lang-py prettyprint-override"><code>class Foo:
def __init__(self):
self.value: int | None = None
def set_value(self, value: int | None):
self.value = value
def test_foo():
foo = Foo()
assert foo.value is None
... | <python><mypy><python-typing> | 2024-03-23 13:51:07 | 3 | 35,267 | Niko Fohr |
78,211,002 | 5,831,073 | Comparison in python without functools.cmp_to_key(func) | <p>I would like to sort a list after doing some complex comparison with the values in it. For instance,</p>
<pre><code>sorted_result = sorted(unsorted_list, key=functools.cmp_to_key(complex_compare), reverse=True)
</code></pre>
<p>where <strong>complex_compare</strong> is the method that is currently doing said compari... | <python><python-3.x><list><sorting> | 2024-03-23 13:17:13 | 1 | 407 | spinyBabbler |
78,210,979 | 1,353,930 | Handle mixed charsets in the same json file | <p>Given I have the following file:</p>
<pre><code>{
"title": {
"ger": "Komödie" (utf8, encoded as c3 b6)
},
"files": [
{
"filename": "Kom�die" (latin1, encoded as f6)
}
]
}
</code></pre>
<p>(might look differently if you try to ... | <python><json><character-encoding><jq> | 2024-03-23 13:09:29 | 1 | 5,504 | Daniel Alder |
78,210,916 | 1,209,675 | Cython not recognizing Numpy types | <p>I'm learning Cython and can't get a simple example to work. I have the following code to compute a sigmoid function:</p>
<pre><code>import numpy as np
cimport numpy as cnp
cdef inline cnp.float32_t _sigmoid(cnp.float32_t x):
return 1/(1 + np.exp(-x))
</code></pre>
<p>Compiling gives an error <code>'float32_t' ... | <python><numpy><cython> | 2024-03-23 12:49:48 | 0 | 335 | user1209675 |
78,210,800 | 315,168 | Type hinting Python class with dynamic "any" attribute | <p>I have a Python class that supports "any" attribute through dynamic attribute resolution. This is one of the flavours of "attribute dict" pattern:</p>
<pre><code>class ReadableAttributeDict(Mapping[TKey, TValue]):
"""
The read attributes for the AttributeDict types
&quo... | <python><pycharm><python-typing> | 2024-03-23 12:09:49 | 1 | 84,872 | Mikko Ohtamaa |
78,210,495 | 4,906,944 | Getting FolderID and folder name inside a particular folder in Google Drive | <p>I am using Colab in Python to get the folder ID and folder name inside a particular folder called myProject from Google Drive.</p>
<p><strong>Folder structure is like this:</strong></p>
<pre><code>Google Drive (When I open drive.google.com I see the below folder structure)
myProject
ImageToDoc
images
... | <python><google-drive-api><google-colaboratory><google-api-python-client><service-accounts> | 2024-03-23 10:32:06 | 1 | 2,795 | Sanjana Nair |
78,210,428 | 2,667,066 | Regexp for positions of runs of alternating characters | <p>I would like to find multiple regions within a string (in my case, a DNA sequence) that have the characters C and G alternating, in any order:</p>
<pre><code>str = "ANNNTGCGCCCCGCGGTGCGNNT"
^^^^ ^^^^ ^^^
pos 01234567890123456789012
0 1 2
</code></pre>
<p>Above I've m... | <python><regex> | 2024-03-23 10:09:18 | 2 | 2,169 | user2667066 |
78,210,323 | 3,293,726 | Why does socket.accept() break the unfinished established connection? | <p>I have searched a lot of posts but could not find an answer. I understand that the <code>socket.accept()</code> actually fetches the socket from fully-connected queue. Also, I know because of the blocking IO, we have to rely on the concurrent for multiple connections.</p>
<p>However, my question is what else does <c... | <python><sockets> | 2024-03-23 09:29:45 | 1 | 2,004 | Tengerye |
78,210,272 | 12,415,855 | Django / UploadFileForm only provides No valid form? | <p>i try to create a simple file-upload funcionality with Django using the following code / files -</p>
<p>Its more or less taken from this example:
<a href="https://docs.djangoproject.com/en/5.0/topics/http/file-uploads/" rel="nofollow noreferrer">https://docs.djangoproject.com/en/5.0/topics/http/file-uploads/</a></p>... | <python><django> | 2024-03-23 09:06:57 | 1 | 1,515 | Rapid1898 |
78,210,261 | 710,955 | How to configure inference settings to generate images with the Stable Diffusion XL pipeline? | <p>I'm working with the Stable Diffusion XL (SDXL) model from Hugging Face's diffusers library and I want to set this inference parameters :</p>
<ul>
<li>width: Width of the image in pixels.</li>
<li>height: Height of the image in pixels.</li>
<li>steps: Amount of inference steps performed on image generation.</li>
<li... | <python><pytorch><huggingface-transformers><stable-diffusion> | 2024-03-23 09:03:52 | 1 | 5,809 | LeMoussel |
78,209,984 | 14,224,948 | Problems with deploying my first Django app on Azure | <p>I have tried different approaches, but none of them works. I still get the:
<code>ERROR: No matching distribution found for Python==3.9.18</code>
Or other version I have been trying to use.
I tried:
Installing the version defined in <code>requirements.txt</code> with <code>Set up Python</code> process:</p>
<pre><cod... | <python><django><azure> | 2024-03-23 06:53:07 | 1 | 1,086 | Swantewit |
78,209,821 | 9,874,309 | Unable initialise pub/sub with SparkSession | <p>SO I'm adding Pub/Sub connector in SparkSession to use spark streaming. But every time it gives error that Pub/Sub data source not found. How to fix it !</p>
<pre><code>from pyspark.sql import SparkSession
# Initialize SparkSession
spark = SparkSession \
.builder \
.appName("PubSubSpark") \
.config("... | <python><apache-spark><google-cloud-platform><pyspark><google-cloud-pubsub> | 2024-03-23 05:12:40 | 0 | 1,201 | Chidananda Nayak |
78,209,759 | 6,423,456 | How can I iterate over an AsyncIterator stream in Python with a timeout, without cancelling the stream? | <p>I'm dealing with an object that is an <code>AsyncIterator[str]</code>.
It gets messages from the network, and yields them as strings.
I want to create a wrapper for this stream that buffers these messages, and yields them at a regular interval.</p>
<p>My code looks like this:</p>
<pre class="lang-py prettyprint-over... | <python><asynchronous><python-asyncio> | 2024-03-23 04:35:15 | 1 | 2,774 | John |
78,209,422 | 920,731 | Convert Python Request call to PHP (cURL) | <p>I am pulling my hair out :)</p>
<p>THe company I am using has a API I need to use but only gives an example to me in Python.</p>
<p>Can someone help me write it in PHP? I have tried several times but no luck. I think the problem is in the file sending.</p>
<p>Here is the Python code:</p>
<pre class="lang-none pretty... | <python><php> | 2024-03-23 01:04:03 | 1 | 341 | rsirota |
78,209,132 | 9,848,968 | Scrapy Playwright Page Method: Prevent timeout error if selector cannot be located | <p>My question is related to Scrapy Playwright and how to prevent the Page of a Spider from crashing, if in the course of applying a PageMethod a specific selector cannot be located.</p>
<p>Below is a Scrapy Spider that uses Playwright to interact with the website.
The spider waits for the cookie button to appear and t... | <python><web-scraping><scrapy><playwright><scrapy-playwright> | 2024-03-22 22:35:46 | 2 | 385 | muw |
78,209,123 | 2,612,259 | ipywidget to replace Plotly legend item | <p>I am trying to replace the Plotly provided legend with a custom legend using ipywidgets.
A simple example is below where I have a checkbox for each trace that can be used to "highlight" the trace from the legend.</p>
<p>This seems to work fine, but I would like to reproduce something similar to what Plotl... | <python><plotly><ipywidgets> | 2024-03-22 22:32:54 | 1 | 16,822 | nPn |
78,209,118 | 12,049,252 | Transpose within Transpose Notepad++? | <p>I have a text file that looks like this (but 132k lines)</p>
<pre><code>********
name : one
Place : city
Initial: none
********
name : two
Place : city2
Initial: none
********
name : three
Place : city3
Initial: none
Limits : some
</code></pre>
<p>I'm trying to move it into a more friendly format (excel/database rec... | <python><notepad++> | 2024-03-22 22:31:20 | 1 | 339 | Gene Parmesan |
78,209,115 | 1,492,229 | How to pivot dataframe in python | <p>I have a dataset that looks like this</p>
<pre><code>StID SubClassID PhOrder PhAmt LbOrder LbAmt
4326 200572288 Anti1 23.3 Asprin 13.7
4326 200572288 Anti2 39.3 Morphin 2.2
4326 200572288 NULL NULL Me... | <python><pandas> | 2024-03-22 22:30:27 | 2 | 8,150 | asmgx |
78,209,071 | 3,917,215 | How to identify the root from hierarchical data structure using Pandas | <p>I have a dataframe with the following columns: Parent, Parent_Rev, Child, ChildRev. In this structure, Parent serves as a parent node, while Child functions as a child node. Both Parent_Rev and ChildRev capture different revisions of their respective nodes. A Child may appear in the parent column and have it's own c... | <python><pandas><dataframe> | 2024-03-22 22:13:46 | 1 | 353 | Osceria |
78,209,037 | 3,737,135 | How do I set up pytest parameters for multiple functions at once? | <p>I have the following example unit test set up. There are several classes with their own fixtures. I am showing the 5th class here:</p>
<pre><code>import pytest
class TestOperator1:
....
class TestOperator5:
@pytest.fixture(scope="class"):
def runm0(self, request):
yield request.param+10
... | <python><unit-testing><pytest><python-unittest> | 2024-03-22 21:59:36 | 0 | 432 | Fanylion |
78,209,013 | 1,506,763 | Is there a better way to use multiprocessing within a loop? | <p>I'm quite new to using <code>multiprocessing</code> and I'm trying to figure out if there is a better way to use <code>multiprocessing</code> when it has to be within a loop. Or at least I think it has to be within a loop. Let me try to describe the outline and then a better solution may be obvious.</p>
<p>I'm proce... | <python><python-multiprocessing> | 2024-03-22 21:52:47 | 0 | 676 | jpmorr |
78,208,804 | 3,713,336 | The variable is returning empty in my Python script | <p>I am working on a Python script and using GCP Cloud Build to run it. Instead of hardcoding some of the variables, I am trying to use a Cloud Build YAML file to define the variables there and then use them in my Python script. However, it keeps returning an empty string. Can you review the code and let me know why?</... | <python><google-cloud-platform><google-cloud-build><cloudbuild.yaml><vertex-ai-pipeline> | 2024-03-22 20:57:04 | 0 | 357 | lisa_rao007 |
78,208,735 | 726,730 | Parallel programming: Synchronizing processes | <p>I have a program which has a lot of music decks (deck 1, deck 2, music_clip_deck, speackers_deck, ip_call_1, ip_call_2, ip_call_3). Each deck works in a seperate process. The chunk time I use to crop the mp3 files/retransmitions stream/voice from microphone/voice from aiortc-pyav is 125msec. After that I fill some q... | <python><parallel-processing><multiprocessing><synchronization> | 2024-03-22 20:40:34 | 1 | 2,427 | Chris P |
78,208,703 | 489,088 | In a 2d numpy array, how to select every first and second element of the inner arrays? Can this be done with indexing? | <p>For example the array:</p>
<pre><code>array = np.array([[1, 1, 4, 2, 1, 8],
[1, 1, 8, 2, 1, 16],
[1, 1, 40, 2, 1, 80],
[1, 2, 40, 2, 1, 80]])
</code></pre>
<p>I'd like to essentially remove every third <code>[:, ::2]</code> element of the inner arrays. So the res... | <python><arrays><numpy> | 2024-03-22 20:29:43 | 4 | 6,306 | Edy Bourne |
78,208,450 | 17,142,551 | Rolling sum within 30 non-datetime days | <p>I've been racking my brain trying to figure out the best way to do this. I want to find the rolling sum of the previous 30 days but my 'day' column is not in datetime format.</p>
<p>Sample data</p>
<pre><code>df = pd.DataFrame({'client': ['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B'... | <python><pandas> | 2024-03-22 19:22:49 | 1 | 1,842 | amance |
78,208,433 | 7,228,014 | ModuleNotFoundError after upgrade | <p>I used to work with python version 3.9 in Jupyter lab.
When I tried to install skrub, an extension of sk-learn, it appeared that I needed a version greater than 3.10. So, I installed the lastest python version, i.e 3.12.</p>
<p>Once in Jupyter, I checked the version using <code>! python --version</code>. It confirme... | <python><upgrade><python-3.12> | 2024-03-22 19:19:44 | 1 | 309 | JCF |
78,208,414 | 17,800,932 | Emitting a `Signal` to directly transition a `QStateMachine` to another `QState` | <p>I have the following state machine:</p>
<p><a href="https://i.sstatic.net/v036f.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/v036f.png" alt="enter image description here" /></a></p>
<p>I have implemented this in Python via the standard state pattern. This state machine is running in a separate thre... | <python><pyqt><pyside><pyside6><qstatemachine> | 2024-03-22 19:14:20 | 1 | 908 | bmitc |
78,208,230 | 1,377,288 | How can I convert a PredictResponse to JSON? | <p>I have a VertexAI project I want to access. I'm currently trying two approaches, via a React frontend and via a Python backend, which I would then connect to the FE. I posted a question about making requests to VertexAI from Node <a href="https://stackoverflow.com/questions/78208092/how-to-send-a-request-to-a-vertex... | <python><json><google-cloud-platform><google-cloud-vertex-ai> | 2024-03-22 18:28:29 | 1 | 527 | Tuma |
78,208,171 | 6,573,259 | How do you create a semi-transaparent image in numpy and saving it in pillows as PNG | <p>Hello I would like to create a semi-transparent image. What i thought would be straight forward turns out not to be. I created a 1000x1000 pixel array with a depth of 4 (B,G,R,A channels). I initialized them to all 0 thinking that they would produce full black but also fully transparent base image. I then draw a gre... | <python><numpy><python-imaging-library> | 2024-03-22 18:17:02 | 1 | 752 | Jake quin |
78,208,112 | 9,703,039 | Why is my function not behaving asynchronously (asyncio to_thread)? | <p>Learning from <a href="https://www.youtube.com/watch?v=p8tnmEdeOU0" rel="nofollow noreferrer">this video</a>, I'm trying to make my codes run faster.<br />
I have a synchronous get function (here represented by <code>mySynchronousFunction</code>) that I want to evaluate over several values in a List.<br />
I am codi... | <python><python-3.x><python-asyncio> | 2024-03-22 18:05:49 | 1 | 339 | Odyseus_v4 |
78,208,034 | 19,024,379 | How to get property return type annotation? | <p>I'm looking for a way to extract the return type annotation of a property from a class, e.g.:</p>
<pre class="lang-py prettyprint-override"><code>class Test:
@property
def foo(self) -> int:
return 1
print(return_type_extract(Test, 'foo')) # <class 'int'>
</code></pre>
<p>For standard method... | <python><python-typing> | 2024-03-22 17:48:34 | 1 | 1,172 | Mark |
78,207,990 | 17,884,397 | Sum each column of a sparse matrix multiplied by a vector | <p>I have a large scipy <strong>sparse</strong> matrix <code>X</code>.<br />
I have a vector, <code>y</code> with the number of elements matches the number of rows of <code>X</code>.</p>
<p>I want to calculate the sum of of each column after it was multiplies by <code>y</code>.<br />
If <code>X</code> was dense, it is ... | <python><numpy><performance><scipy><sparse-matrix> | 2024-03-22 17:37:26 | 1 | 736 | Eric Johnson |
78,207,986 | 6,458,245 | How to debug ValueError: `FlatParameter` requires uniform dtype but got torch.float32 and torch.bfloat16? | <p>I'm trying to do Pytorch Lightning Fabric distributed FSDP training with Huggingface PEFT LORA fine tuning on LLAMA 2 but my code ends up failing with:</p>
<pre><code>`FlatParameter` requires uniform dtype but got torch.float32 and torch.bfloat16
File ".......", line 100, in <module>
model, opt... | <python><distributed-computing><pytorch-lightning> | 2024-03-22 17:36:39 | 1 | 2,356 | JobHunter69 |
78,207,971 | 7,648,650 | minimizing portfolio tracking error yield unlogical results | <p>I have a <code>pd.DataFrame</code> with daily stock returns of shape <code>(250,10)</code> and a <code>pd.Series</code> with my benchmarks daily returns of shape <code>(250,)</code>. The goal is to minimize the Tracking Error, between a portfolio of stocks and the benchmark.
The tracking error is the Standard Deviat... | <python><optimization><scipy><scipy-optimize><portfolio> | 2024-03-22 17:34:00 | 1 | 1,248 | Quastiat |
78,207,901 | 1,100,913 | Poetry packaging several dependencies | <p>I have a project with several packages:</p>
<pre><code>Project
|---PackageA
|------dist
|----------packagea.whl
|------pyproject.toml
|---PackageB
|------dist
|----------packageb.whl
|------pyproject.toml
</code></pre>
<p>PackageB has PackageA as a dependency.</p>
<p>Right now I have PackageB pypro... | <python><python-packaging><python-poetry> | 2024-03-22 17:21:10 | 0 | 953 | Andrey |
78,207,696 | 5,211,659 | `Unsupported object type int` when passing a `pandas.core.frame.DataFrame` to tensorflow.convert_to_tensor() | <p>I keep getting the error <code>Unsupported object type int</code> when passing a pandas <code>DataFrame</code> to <code>tensorflow.convert_to_tensor()</code>. I've already converted all columns to types supported by tensorflow. So I'm not sure why it's still not working. This is the dataframe:</p>
<pre><code><cla... | <python><pandas><numpy><tensorflow> | 2024-03-22 16:43:33 | 0 | 821 | Daniel Becker |
78,207,668 | 6,379,348 | unable to extract text from span tag using Beautifulsoup and Request | <p>I'm trying to scrap posts from this online forum. <a href="https://csn.cancer.org/categories/prostate" rel="nofollow noreferrer">https://csn.cancer.org/categories/prostate</a>
All post seems to be in span tags.</p>
<p>I used the code below to scrap the posts.</p>
<pre><code>import requests
from bs4 import BeautifulS... | <python><web-scraping><beautifulsoup><python-requests> | 2024-03-22 16:37:39 | 2 | 11,903 | zesla |
78,207,583 | 6,151,828 | pandas.read_csv : load only certain columns and the unnamed index | <p>While working with a large dataset, I would like to load only a part of it (more precisely - I would like to load only the training data samples) as loading the full dataset takes some time and memory. I know the names of the columns of interest, but the index column is unnamed. The trouble is that (to my knowledge)... | <python><pandas><dataframe> | 2024-03-22 16:23:57 | 1 | 803 | Roger V. |
78,207,433 | 11,474,852 | How can spark.version be different from installed pyspark version? | <p>I'm working in a Python virtual environment in which I have installed pyspark version 3.5.0:</p>
<pre class="lang-bash prettyprint-override"><code>$ pip show pyspark
Name: pyspark
Version: 3.5.0
Summary: Apache Spark Python API
Home-page: https://github.com/apache/spark/tree/master/python
Author: Spark Developers
Au... | <python><apache-spark><pyspark> | 2024-03-22 15:57:20 | 0 | 605 | Kai Roesner |
78,207,307 | 10,461,632 | Converting YAML file to dataclass with nested dataclasses and optional keyword arguments | <p>I want to read in a YAML file and convert it into a python dataclass. The goal in this example is to be able to produce the same dataclass.</p>
<p>Without reading a YAML file:</p>
<pre><code>from dataclasses import dataclass, field
@dataclass
class OptionsSource:
a: str
b: str = None
kwargs: dict = fie... | <python><yaml><python-dataclasses> | 2024-03-22 15:34:50 | 5 | 788 | Simon1 |
78,207,298 | 10,997,298 | Trying to slice a large css file Trying to slice a large css file (1,952,726 rows) to chances using Python | <p>When I run the following command, I get an error:</p>
<pre><code>import pandas as pd
import os
import numpy as np
Endcustomers = "Resources/WESTCON_INTE_LTD_2024_01_GBP.csv"
Endcustomers_df = pd.read_csv(Endcustomers)
Endcustomers_df.head(3)
def split_csv_into_chunks(Endcustomers, 10000):
# Read the ... | <python><split><chunks> | 2024-03-22 15:33:24 | 1 | 685 | RedaB |
78,207,291 | 11,474,852 | How to use Spark Connect with pyspark on Python 3.12? | <p>I'm trying to use Spark Connect to create a Spark session on a remote Spark cluster with pyspark in Python 3.12:</p>
<pre class="lang-py prettyprint-override"><code>ingress_ep = "..."
access_token = "..."
conn_string = f"sc://{ingress_ep}/;token={access_token}"
spark = SparkSession.buil... | <python><pyspark><setuptools><spark-connect> | 2024-03-22 15:31:45 | 1 | 605 | Kai Roesner |
78,207,024 | 3,214,538 | Uploading large amounts of data in bulk to a Cloud SQL instance via Python | <p>I have a Python application that uses a Cloud SQL instance to store data. The application usually runs on a Google Compute Engine but is run locally during development and testing. At some point I need to update two separate tables with a number of rows in the order of one hundred thousands rows each. Rows will alre... | <python><mysql><sqlalchemy> | 2024-03-22 14:48:52 | 0 | 443 | Midnight |
78,206,985 | 9,703,039 | Fill Pandas Dataframe asynchronously with async | <p>I just saw <a href="https://www.youtube.com/watch?v=p8tnmEdeOU0" rel="nofollow noreferrer">this awesome video from Idently</a> and tried to use the trick to fill in some dataframe columns according to another.</p>
<p>Here is my MWE (more like non-working example infact) code, I code in a Jupyter notebook.</p>
<pre c... | <python><python-3.x><pandas><python-asyncio> | 2024-03-22 14:42:12 | 1 | 339 | Odyseus_v4 |
78,206,851 | 6,936,682 | Pydantic to load list of nested json objects thows missing value | <p>I have the following pydantic objects:</p>
<pre><code>class NestedObject(BaseModel):
id: int
class MainObject(BaseModel):
id: int
nested_objects: list[NestedObject]
</code></pre>
<p>Also I have a JSON string that I want pydantic to build the objects from:</p>
<pre><code>bla = """
{
&q... | <python><pydantic> | 2024-03-22 14:18:53 | 0 | 1,970 | Jeppe Christensen |
78,206,782 | 22,824,066 | Python4Delphi GetIt Demos aren't working in Delphi 12 | <p>I just downloaded Python4Delphi from getIt and after it finished installing, it opened the demos for me.</p>
<p>When I run the demos, I just keep getting errors:</p>
<blockquote>
<p>Error 87: Could not open Dll "python33.dll"</p>
</blockquote>
<blockquote>
<p>Python could not be properly initialized. We mu... | <python><delphi><delphi-12-athens><python4delphi> | 2024-03-22 14:07:53 | 0 | 632 | Martin Kakhuis |
78,206,706 | 2,409,793 | Python module not imported despite file being there | <p>I have a <code>python</code> project. I have activated <code>virtualenv</code> for it and installed <code>requirements.txt</code></p>
<p>Here is my files/dirs structure</p>
<pre><code>.
├── app
│ ├── app.py
│ ├── modules
│ │ ├── __pycache__
│ │ ├── foo.py
│ │ ├── settings.py
│ └── requirements.txt
... | <python><python-3.x><import><python-import> | 2024-03-22 13:54:52 | 1 | 19,856 | pkaramol |
78,206,531 | 3,870,664 | Debugging Python AWS CDK application in VSCode | <p>I have a AWS CDK application written in python. I want to debug this in VSCode. I do understand this would not be the normal convention. Since in my case cdk is installed globally and the cdk.json directs the global cdk to run my <code>"app": "python3 app.py"..</code> and at runtime cdk is using ... | <python><aws-cdk><vscode-debugger> | 2024-03-22 13:20:32 | 0 | 1,508 | vfrank66 |
78,206,446 | 1,745,291 | Is there a simple way to subclass python's set without redefining all operators? | <p>Is there a way to subclass <code>set</code>, with the binary operator returning the subclassed type, without redefining them ?</p>
<p>example :</p>
<pre><code>class A(set):
pass
a = A([1,2,3]) & A([1,2,4])
a.__class__ == A # it's False, and I would like it to be true without redefining all operators
</cod... | <python><python-3.x><subclassing> | 2024-03-22 13:05:51 | 2 | 3,937 | hl037_ |
78,206,353 | 3,934,271 | Unable to generate plantuml diagram when trying to use "iplantuml" in Jupyter Notebook within vscode | <p>I'm trying to use iplantuml in jupyter notebook within VS Code.</p>
<p><a href="https://i.sstatic.net/OqFaH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OqFaH.png" alt="enter image description here" /></a></p>
<p>Keep getting this error:</p>
<pre class="lang-none prettyprint-override"><code>-------... | <python><visual-studio-code><jupyter-notebook><plantuml> | 2024-03-22 12:50:26 | 1 | 1,590 | jas |
78,206,317 | 9,112,151 | itemgetter for nested dict key value | <p>I'd like to get a nested dict value with <code>itemgetter</code>:</p>
<pre><code>from operator import itemgetter
dct = {"name": {"en": "John"}}
getter = itemgetter("name", "en")
getter(dct)
</code></pre>
<p>The code gives me error:</p>
<pre><code>Traceback (most rec... | <python><dictionary> | 2024-03-22 12:43:20 | 4 | 1,019 | Альберт Александров |
78,206,137 | 606,576 | How to type hint an overloaded decorator that may be sync or async | <p>Python 3.10.</p>
<p>I have written two versions of a logging decorator, one for normal functions and one for async functions. Mypy is happy with these:</p>
<pre class="lang-py prettyprint-override"><code>from functools import wraps
from inspect import Signature, signature
from logging import getLogger
from typing im... | <python><overloading><mypy><python-decorators><python-typing> | 2024-03-22 12:08:22 | 0 | 915 | kthy |
78,205,950 | 8,176,763 | FastAPI oauth2 + jwt extend exp time at every request | <p>According to the example of fastapi, we can use ouath2 and json web tokens to create login for users:</p>
<pre><code>from datetime import datetime, timedelta, timezone
from typing import Annotated
from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.security import OAuth2PasswordBearer, OAuth2Pa... | <python><jwt><fastapi> | 2024-03-22 11:36:32 | 1 | 2,459 | moth |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.