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 ⌀ |
|---|---|---|---|---|---|---|---|---|
75,267,490 | 14,577,660 | Minus equal operator doesnt call property setter python | <p>I have my code setup this way:</p>
<pre class="lang-py prettyprint-override"><code>class Test():
def __init__(self):
self.offset = [0,0]
@property
def offset(self):
return self._offset
@offset.setter
def offset(self,offset):
print("set")
self._offset = ... | <python><python-3.x><getter-setter> | 2023-01-28 12:01:52 | 1 | 316 | Anatole Sot |
75,267,445 | 12,579,308 | Why does onnxruntime fail to create CUDAExecutionProvider in Linux(Ubuntu 20)? | <pre><code>import onnxruntime as rt
ort_session = rt.InferenceSession(
"my_model.onnx",
providers=["CUDAExecutionProvider"],
)
</code></pre>
<p>onnxruntime (onnxruntime-gpu 1.13.1) works (in Jupyter VsCode env - Python 3.8.15) well when <em>providers</em> is <code>["CPUE... | <python><onnxruntime> | 2023-01-28 11:55:24 | 6 | 341 | Oguz Hanoglu |
75,267,419 | 17,696,880 | Regex of replacements conditioned by previous regex patterns fails to capture any of the strings | <pre class="lang-py prettyprint-override"><code>import re
input_text = "En esta alejada ciudad por la tarde circulan muchos camiones con aquellos acoplados rojos, grandes y bastante pesados, llevándolos por esos trayectos bastante empedrados, polvorientos, y un tanto arenosos. Y incluso bastante desde lejos ya se... | <python><python-3.x><regex><replace><regex-group> | 2023-01-28 11:51:52 | 0 | 875 | Matt095 |
75,267,090 | 14,368,631 | Convert a recursive jump point search implementation into an iterative implementation | <p>So I've got this recursive function which I want to convert to an iterative version. How could I do this?</p>
<pre class="lang-py prettyprint-override"><code>def jump(grid: np.ndarray, current: Point, parent: Point, end: Point) -> Point | None:
if not reachable(grid, *current):
return None
if cur... | <python><a-star> | 2023-01-28 10:54:19 | 0 | 328 | Aspect11 |
75,266,962 | 17,174,267 | numpy ndarray: print imaginary part only if not zero | <p>Continuing this question <a href="https://stackoverflow.com/questions/2891790/pretty-print-a-numpy-array-without-scientific-notation-and-with-given-precision">here</a>, I'd like to ask how I can print a complex numpy array in a way that prints the imaginary part only if it's not zero. (This also goes for the real pa... | <python><python-3.x><numpy><formatting><pretty-print> | 2023-01-28 10:31:45 | 2 | 431 | pqzpkaot |
75,266,838 | 9,267,178 | Error when using select_one() however working fine with find() method | <p>This is my code and when I convert it to select_one() method, it gives me error.</p>
<p>Code:</p>
<pre><code>response = requests.get("https://near.org/blog/",headers=headers)
soup = BeautifulSoup(response.text, 'lxml').find("div", class_="bg-[#ffffff] grow rounded-br-[10px] rounded-bl-[10px]... | <python><beautifulsoup> | 2023-01-28 10:07:03 | 1 | 420 | Avi Thour |
75,266,566 | 8,380,638 | Best way to send image through GRPC using protobuf | <p>I am currently using python grpc. My intention is to send an image to my GRPC server using the minimum payload size. My proto looks like the following:</p>
<pre><code>message ImageBinaryRequest {
// Image as bytes
bytes image = 1;
}
</code></pre>
<p>And my client encode images like this:</p>
<pre><code>def get_b... | <python><image><serialization><grpc> | 2023-01-28 09:12:29 | 1 | 1,761 | m33n |
75,266,414 | 6,224,317 | Notify python orion/quantumleap subscription changes | <p>Is there any way to get notified in python when a Quantumleap o Orion subscription fires for a changed value?</p>
| <python><fiware><fiware-orion> | 2023-01-28 08:44:18 | 2 | 654 | drypatrick |
75,266,188 | 1,497,139 | pyparsing syntax tree from named value list | <p>I'd like to parse tag/value descriptions using the delimiters :, and •</p>
<p>E.g. the Input would be:</p>
<pre><code>Name:Test•Title: Test•Keywords: A,B,C
</code></pre>
<p>the expected result should be the name value dict</p>
<pre class="lang-py prettyprint-override"><code>{
"name": "Test",
&qu... | <python><pyparsing> | 2023-01-28 07:55:23 | 3 | 15,707 | Wolfgang Fahl |
75,266,027 | 3,209,270 | How do you run a portion of a python script that requires superuser privileges, while the rest does not? | <p>I'm trying to make a script that will detect the color of a pixel, and have a keybind (say F5) to trigger this action.</p>
<p>The pixel scan portion can be done with something like this (put together from what I've found):</p>
<pre><code>from Xlib import display, X
from PIL import Image
dsp = display.Display()
root... | <python><linux><ubuntu><gnome><xlib> | 2023-01-28 07:20:44 | 0 | 1,095 | dev404 |
75,265,971 | 3,247,006 | Cannot the parent model's object use `_set` with `OneToOneField()` in Django? | <p>I have <code>Person</code> model and <code>PersonDetail</code> model with <a href="https://docs.djangoproject.com/en/4.2/ref/models/fields/#onetoonefield" rel="nofollow noreferrer">OneToOneField()</a> as shown below:</p>
<pre class="lang-py prettyprint-override"><code>class Person(models.Model):
name = models.Ch... | <python><django><django-models><django-queryset><one-to-one> | 2023-01-28 07:08:15 | 1 | 42,516 | Super Kai - Kazuya Ito |
75,265,964 | 5,062,559 | Remove JSON list string items based on a list of strings | <p>Following is my sample json file:</p>
<pre><code> {
"test": [{
"Location": "Singapore",
"Values": [{
"Name": "00",
"subvalues": [
"5782115e1&qu... | <python><json> | 2023-01-28 07:06:34 | 2 | 363 | Knight |
75,265,932 | 2,277,549 | Is it good practice in python to store auth data in class attribute? | <p>I want to access multiple google calendars from python: there is a primary calendar connected to a google account, also other (secondary) calendars can be created. Access to the secondary calendars is possible after google authorization to the primary one. I want to make changes to the secondary calendars without re... | <python><oop><class-method> | 2023-01-28 06:59:32 | 1 | 325 | zeliboba7 |
75,265,467 | 13,049,379 | Correct way of using "not in" operator | <p>We know that,</p>
<pre><code>a = 1
b = 2
print(not a > b)
</code></pre>
<p>is the correct way of using the "not" keyword and the below throws an error</p>
<pre><code>a = 1
b = 2
print(a not > b)
</code></pre>
<p>since "not" inverts the output Boolean.</p>
<p>Thus, by this logic the correc... | <python> | 2023-01-28 04:59:24 | 4 | 1,433 | Mohit Lamba |
75,265,398 | 3,324,136 | Pandas: groupby multiple columns for bar graph | <p>I have a CSV of financial data that is listed by:</p>
<ol>
<li>Date</li>
<li>Category</li>
<li>Amount</li>
</ol>
<p>The dataset looks like the following, with another hundred rows. I am trying to use pandas to graph this data by month and then the total by each category. An example would be a bar graph of each mon... | <python><pandas><dataframe> | 2023-01-28 04:40:26 | 1 | 417 | user3324136 |
75,265,239 | 2,655,127 | Python Selenium webdriver get XPATH and select dropdown | <p>I've found the word 'Burger' in HTML table with this code</p>
<pre><code>findRow = driver.find_element(By.XPATH, "//*[contains(text(),'Burger')]").value_of_css_property('#name')
</code></pre>
<ol>
<li>how do I can get XPATH 'Burger'?</li>
<li>how do I can select the column beside it (example select 'Fish' ... | <python><python-3.x><selenium><selenium-webdriver> | 2023-01-28 03:48:06 | 3 | 853 | jack |
75,265,200 | 9,576,988 | Flattening a pandas dataframe by creating new columns resulting in unique ID pairs | <p>I have a pandas dataframe like:</p>
<pre><code> id sid X_animal X_class Y_animal Y_class
0 1 A 88 Home Monkey Mammal
1 1 A 88 Home Parrot Bird
2 1 B
3 2 C 11 Work
4 2 C 11 Work
5 2 C 33 School Dog Mammal
6 3 D 44 Home S... | <python><pandas><pivot><transform> | 2023-01-28 03:34:01 | 1 | 594 | scrollout |
75,265,187 | 2,366,887 | I can't get my python program to see my local modules | <p>I am running VSCode on Windows 10. I've set up a virtual environment and have installed a number of packages to the local site library.</p>
<p>I've activated my environment (The terminal prompt shows a .venv string)
However, when I attempt to import any of my local modules, I get an 'Module not found'
error.</p>
<p... | <python><visual-studio-code><python-import><python-venv><python-packaging> | 2023-01-28 03:31:21 | 2 | 523 | redmage123 |
75,265,105 | 164,185 | How can I debug a python application | <p>I am quite new to python and trying to understand how can I troubleshoot an issue in a python application which is using python api to call functions in a C library. Looks like respective C function is not able to process things as expected. I am not sure how can i troubleshot the same without adding more printfs a... | <python><python-3.x><gdb><pdb> | 2023-01-28 03:02:33 | 0 | 4,595 | codingfreak |
75,265,045 | 15,637,940 | calculate if number bigger than defined percent of numbers in list without storing list in memory after first calculation | <p>I have <code>percent value</code> and <code>list</code> with <em>fixed</em> length (mean that list must always has same length). In loop inputting <code>x</code> with type <code>int</code>. Task is to know if <code>x</code> is <strong>bigger</strong> than %
of elements, after delete first element and append to end i... | <python><math> | 2023-01-28 02:42:47 | 1 | 412 | 555Russich |
75,264,792 | 9,206,667 | Building Python3.6.15 and SQLite-3.20.1 *FROM SOURCE* and Getting Wrong SQLite3 version in Python | <p>There are a number of posts about this issue, although most of them do not apply because I am building from source into NON-STANDARD locations.</p>
<p>I'm on CentOS7.</p>
<p>I have compiled/installed sqlite3 from source to a NON-STANDARD location. Let's call it <code>/opt/sqlite-3.20.1</code>.</p>
<p>My Python-3.6.... | <python><python-3.x><sqlite><python-3.6> | 2023-01-28 01:29:12 | 0 | 1,283 | Lance E.T. Compte |
75,264,771 | 5,986,907 | Postgres docker "server closed the connection unexpectedly" | <p>I want to run and connect to the postgresql Docker image in Python using SQLModel. Here's my attempt</p>
<pre><code>from contextlib import contextmanager
import docker
from sqlmodel import create_engine, SQLModel, Field
DEFAULT_POSTGRES_PORT = 5432
class Foo(SQLModel, table=True):
id_: int = Field(primary_ke... | <python><postgresql><docker><sqlmodel> | 2023-01-28 01:21:33 | 1 | 8,082 | joel |
75,264,697 | 2,882,380 | Computing time in Python [Python for Data Analysis 3E] | <p>In <a href="https://wesmckinney.com/book/numpy-basics.html" rel="nofollow noreferrer">Chapter 4 of Python for Data Analysis 3E</a>, it shows the following example and claims that numpy should be much faster.</p>
<p><a href="https://i.sstatic.net/t1FQv.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/t1... | <python><numpy><time> | 2023-01-28 01:00:36 | 1 | 1,231 | LaTeXFan |
75,264,512 | 1,492,229 | How to upgrade a python library in a supercomputer | <p>I am using Tinaroo (University of Queensland) super computer</p>
<p>When I call to run my code using</p>
<pre><code>qsub 70my_01_140239.sh
</code></pre>
<p>I get this error</p>
<pre><code>autosklearn.util.dependencies.IncorrectPackageVersionError: found 'dask' version 2021.11.2 but requires dask version >=2021.12... | <python><linux><supercomputers><auto-sklearn> | 2023-01-28 00:14:30 | 1 | 8,150 | asmgx |
75,264,456 | 7,648 | ValueError: Inputs have incompatible shapes | <p>I have the following code:</p>
<pre><code>def fcn8_decoder(convs, n_classes):
# features from the encoder stage
f3, f4, f5 = convs
# number of filters
n = 512
# add convolutional layers on top of the CNN extractor.
o = tf.keras.layers.Conv2D(n , (7 , 7) , activation='relu' , padding='same', name="... | <python><tensorflow><deep-learning><image-segmentation> | 2023-01-28 00:01:24 | 4 | 7,944 | Paul Reiners |
75,264,444 | 851,699 | Tkinter message box crash: Process finished with exit code 133 (interrupted by signal 5: SIGTRAP) | <p>I have a hard-to-replicate crash when using <code>tkinter.messagebox</code> on a MacOS Monterey 12.2.1, python 3.8.13.</p>
<p>The system crashes about 50% of the time when I call <code>messagebox.showinfo(...)</code> or any of the functions under <code>messagebox</code>, with <code>Process finished with exit code 13... | <python><tkinter> | 2023-01-27 23:58:25 | 1 | 13,753 | Peter |
75,264,394 | 5,623,335 | Class function vs method? | <p>I was watching <strong>Learn Python - Full Course for Beginners [Tutorial]</strong> on YouTube <a href="https://www.youtube.com/watch?v=rfscVS0vtbw" rel="nofollow noreferrer">here</a>.</p>
<p>At timestamp <strong>4:11:54</strong> the tutor explains what a <em>class function</em> is, however from my background in obj... | <python><python-3.x><class><oop><methods> | 2023-01-27 23:48:10 | 3 | 303 | securityauditor |
75,264,349 | 7,936,836 | how to delay python function without affect imported .py? | <p>Two .py in one folder:<br />
a.py:</p>
<pre><code>def main():
a=1
while a<100:
a++
print(a)
</code></pre>
<p>b.py:</p>
<pre><code>import a
s=time.time()
e=s
while (e-s)<5:
a.main()
time.sleep(3)
e=time.time()
</code></pre>
<p>During <code>time.sleep(3)</code>,<code>a.main</code> will be block... | <python> | 2023-01-27 23:41:09 | 1 | 2,511 | kittygirl |
75,264,339 | 5,468,372 | sending file to host on update from inside docker container | <p>my python program in a docker container updates a log file. Every time this happens, I want this file to be copied to host.
My folder structure is like that:</p>
<pre><code>Dockerfile
my_program
\___ log
\__ my_log.log
\___ run_my_program.py
</code></pre>
<p>This is my dockerfile:</p>
<pre><code># sta... | <python><bash><docker><logging> | 2023-01-27 23:38:35 | 0 | 401 | Luggie |
75,264,327 | 2,301,970 | Slincing a pandas MultiIndex dataframe by one index where two row index value exist | <p>I wonder if anyone could please offer some advice:</p>
<p>I have a data set with the following structure:</p>
<pre><code>import pandas as pd
# Create individual pandas DataFrame.
df1 = pd.DataFrame({'Col1': [1, 2, 3, 4], 'Col2': [99, 98, 95, 90]}, index=['A', 'B', 'C', 'D'])
df2 = pd.DataFrame({'Col1': [1, 2], 'Col... | <python><pandas> | 2023-01-27 23:36:11 | 2 | 693 | Delosari |
75,264,222 | 7,893,438 | argsort() only positive and negative values separately and add a new pandas column | <p>I have a dataframe that has column , 'col', with both positive and negative numbers. I would like run a ranking separately on both the positive and negative numbers only with 0 excluded not to mess up the ranking. My issue is that my code below is updating the 'col' column. I must be keeping a reference it but not... | <python><pandas><dataframe><numpy> | 2023-01-27 23:12:11 | 2 | 391 | John Holmes |
75,264,107 | 3,903,479 | Authenticate with Exchange to access email inbox with imaplib | <p>I have a python script that used to login to an outlook inbox:</p>
<pre class="lang-py prettyprint-override"><code>from imaplib import IMAP4_SSL
imap = IMAP4_SSL("outlook.office365.com")
imap.login("user", "password")
</code></pre>
<p>It now fails with an error:</p>
<pre><code>Tracebac... | <python><python-3.x><azure><oauth><imaplib> | 2023-01-27 22:54:39 | 1 | 1,942 | GammaGames |
75,264,015 | 6,077,239 | How can I rotate/shift/increment one particular column's values in Polars DataFrame? | <p>I have a polars dataframe as follows:</p>
<pre class="lang-py prettyprint-override"><code>df = pl.from_repr("""
┌─────┬───────┐
│ day ┆ value │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═══════╡
│ 1 ┆ 1 │
│ 1 ┆ 2 │
│ 1 ┆ 2 │
│ 3 ┆ 3 │
│ 3 ┆ 5 │
│ 3 ┆ 2 │
│ 5 ┆ 1 ... | <python><python-polars> | 2023-01-27 22:41:24 | 2 | 1,153 | lebesgue |
75,263,977 | 12,436,050 | Append columns of pandas dataframe based on a regex | <p>I have two dataframes which I would like to append based on a regex. If the value in a 'code' column of df1 matches (eg. R93) with the 'ICD_CODE' of df2(eg. R93), append the 'code' column value to df2.</p>
<pre><code>df1
code
R93.2
S03
df2
ICD_CODE ICD_term MDR_code MDR_term
R93.1 ... | <python><pandas> | 2023-01-27 22:35:02 | 2 | 1,495 | rshar |
75,263,968 | 825,372 | Why does the SQLAlchemy documentation put the add operation inside try/except without a flush operation? | <p>I'm trying to understand SQLAlchemy (1.4) and I can't quite put things together. I can find examples that put either <code>session.commit()</code> (<a href="https://stackoverflow.com/questions/2193670/catching-sqlalchemy-exceptions/4430982#4430982">SO</a>, <a href="https://docs.sqlalchemy.org/en/14/faq/sessions.html... | <python><sqlalchemy> | 2023-01-27 22:33:21 | 0 | 1,646 | Steffen |
75,263,896 | 4,350,515 | How can I download the CSV file from a Bank of England webpage using Python? | <p>I would like to programmatically download the CSV file of the Official Bank Rate history on this page: <a href="https://www.bankofengland.co.uk/boeapps/database/Bank-Rate.asp" rel="nofollow noreferrer">https://www.bankofengland.co.uk/boeapps/database/Bank-Rate.asp</a>
There is a link labelled CSV that is clicked to ... | <python><web-scraping> | 2023-01-27 22:24:57 | 1 | 476 | Jonathan Roberts |
75,263,744 | 3,088,891 | Adding bar labels shrinks dodged bars in seaborn.objects | <p>I am trying to add text labels to the top of a grouped/dodged bar plot using <strong>seaborn.objects</strong>.</p>
<p>Here is a basic dodged bar plot:</p>
<pre class="lang-py prettyprint-override"><code>import seaborn.objects as so
import pandas as pd
dat = pd.DataFrame({'group':['a','a','b','b'],
... | <python><seaborn><plot-annotations><grouped-bar-chart><seaborn-objects> | 2023-01-27 22:00:18 | 1 | 1,253 | NickCHK |
75,263,636 | 2,455,888 | How to use regular expressions word boundary for exact match? | <p>I have a string <code>"Volcano - V3 (2010-2020) blah blah TheVolcano - V3 (2010-2020)"</code>. I am trying to search search only <code>Volcano - V3 (2010-2020)</code>.<br />
I used word boundary in the regex as follows:</p>
<pre><code>>>> import re
>>> pattern = "Volcano - V3 (2010-2... | <python><regex> | 2023-01-27 21:44:19 | 1 | 106,472 | haccks |
75,263,316 | 6,392,779 | Discord PY Using Lambda with channel.history().find(), possible? Trying to find latest message by all users (activity check) | <p>I am trying to use this snippet of code I found to check for last time a user messaged on any channel in the Discord server. The source I found is to for oldest message but looks to do what I need - but I get an error on channel.history().find. The error is:</p>
<pre><code>AtrributeError: async_generator object has ... | <python><discord.py> | 2023-01-27 21:00:33 | 2 | 901 | nick |
75,263,208 | 10,396,469 | How to get all XPaths from XML with just key names and no template URLs, with Python | <p>I need to extract XPaths and values from XML object. Currently I use <code>lxml</code> which with either gives long paths with repeated template URLS or just indices of XPaths keys without names.</p>
<p>Question: How to get Xpaths with just names, without template URLs.
Yes, string cleanup after parsing works, but I... | <python><xml><xml-parsing><lxml> | 2023-01-27 20:48:35 | 1 | 4,852 | Poe Dator |
75,263,113 | 875,295 | Sharing instance of proxy object across processes results in pickle errors | <p>I'm trying to implement a simple shared object system in python between several processes.
I'm doing the following:</p>
<pre><code>import os
from multiprocessing.managers import SyncManager
if __name__ == '__main__':
manager = SyncManager(authkey=b'test')
manager.start()
address = manage... | <python><python-multiprocessing> | 2023-01-27 20:35:59 | 3 | 8,114 | lezebulon |
75,263,023 | 471,671 | How can I use Python's concurrent.futures to queue tasks across multiple processes each with their own thread pool? | <p>I'm working on a library function that uses <code>concurrent.futures</code> to spread network I/O across multiple threads. Due to the Python GIL I'm experiencing a slowdown on some workloads (large files), so I want to switch to multiple processes. However, multiple processes will also be less than ideal for some ot... | <python><python-3.x><multiprocessing><concurrent.futures><queueing> | 2023-01-27 20:25:25 | 1 | 20,043 | Andrew Gorcester |
75,262,986 | 4,635,106 | Escaping matched strings before replacing in re.sub | <p>I need to chain matching two user supplied patterns where in between matches I replace the captured matched content in the second pattern.</p>
<pre><code>pattern 1 -> match data 1 -> replace captured matches in pattern 2 -> match data2
</code></pre>
<p>To do this safely, I need to escape the captured matche... | <python><python-re> | 2023-01-27 20:20:54 | 0 | 955 | David R. |
75,262,963 | 12,242,085 | How to create a few Machine Learning models through all variables and after each iteration next XGBClassifier is created with 1 less var in Python? | <p>I have DataFrame in Python Pandas like below:</p>
<p><strong>Input data:</strong></p>
<ul>
<li><p>Y - binary target</p>
</li>
<li><p>X1...X5 - predictors</p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th>Y</th>
<th>X1</th>
<th>X2</th>
<th>X3</th>
<th>X4</th>
<th>X5</th>
</tr>
</thead>
<tbod... | <python><for-loop><machine-learning><roc><auc> | 2023-01-27 20:18:43 | 1 | 2,350 | dingaro |
75,262,851 | 4,414,359 | Converting xlsx to Google Sheets in Jupyter | <p>I'm trying to open a xlsx file from Google Drive as a Google Sheets file in Jupyter.</p>
<pre><code>from googleapiclient.discovery import build
from google.oauth2 import service_account
SERVICE_ACCOUNT_FILE = 'gs_credentials.json'
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
creds = None
creds = servi... | <python><google-sheets><jupyter-notebook><xlsx> | 2023-01-27 20:04:05 | 1 | 1,727 | Raksha |
75,262,602 | 19,708,567 | PY, JS Chrome Extension Receiving Events From Python | <p>I'm trying to make a python script that sends events to a chrome extension when at intervals. I want the python script to send an event to the chrome extension which is listener for an event and will act accordingly based on the data.</p>
<p>I'm not looking for a code solution, I'm just wondering how this could be a... | <javascript><python><google-chrome-extension> | 2023-01-27 19:34:35 | 0 | 465 | walker |
75,262,536 | 4,784,683 | PySide6.QtTest.QTest.mouseClick() - not exposed - is it not meant to be used? | <p>I got the code below from <a href="https://stackoverflow.com/questions/61213729/simulate-the-click-on-a-button-in-the-pyqt5-qmessagebox-widget-during-unittest">this answer</a></p>
<p>In the <a href="https://doc.qt.io/qtforpython/PySide6/QtTest/QTest.html" rel="nofollow noreferrer">docs</a>, <code>mouseClick</code> i... | <python><qt><pyqt> | 2023-01-27 19:25:35 | 0 | 5,180 | Bob |
75,262,502 | 7,211,014 | python virtualenvwrapper refuses to work after upgrade to python3.10 | <p>Keep getting this error when my bashrc is sourced:</p>
<pre><code>/usr/bin/python: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not i... | <python><python-3.x><module><virtualenv><virtualenvwrapper> | 2023-01-27 19:22:21 | 1 | 1,338 | Dave |
75,262,475 | 2,912,859 | Creating a multidimensional list of similarly named files with different extensions | <p>I have a directory of files that follows this file naming pattern:</p>
<pre><code>alice_01.mov
alice_01.mp4
alice_02.mp4
bob_01.avi
</code></pre>
<p>My goal is to find all files at a given path and create a "multidimensional" list of them where each sublist is the unique name of the file (without extension... | <python> | 2023-01-27 19:19:43 | 1 | 344 | equinoxe5 |
75,262,398 | 10,638,608 | FastAPI read configuration before specifying dependencies | <p>I'm using <a href="https://intility.github.io/fastapi-azure-auth/" rel="nofollow noreferrer">fastapi-azure-auth</a> to make call to my API impossible, if the user is not logged in (doesn't pass a valid token in the API call from the UI to be precise).</p>
<p><strong>My question doesn't have anything to do with this ... | <python><fastapi> | 2023-01-27 19:10:39 | 0 | 1,997 | dabljues |
75,262,306 | 6,280,556 | Distributing a python function across multiple worker nodes | <p>I'm trying to understand what would be a good framework that integrates easily with existing python code and allows distributing a huge dataset across multiple worker nodes to perform some transformation or operation on it.</p>
<p>The expectation is that each worker node should be assigned data based on a specific k... | <python><pyspark><distributed-computing><ray> | 2023-01-27 18:59:07 | 2 | 578 | Tushar |
75,262,002 | 3,247,006 | What are "Forward Foreign Key" and "Reverse Foreign Key" in Django? | <p>When reading the topics related to Django's <a href="https://docs.djangoproject.com/en/4.0/ref/models/querysets/#django.db.models.query.QuerySet.select_related" rel="nofollow noreferrer">select_related()</a> and <a href="https://docs.djangoproject.com/en/4.0/ref/models/querysets/#prefetch-related" rel="nofollow nore... | <python><django><django-models><reverse-foreign-key> | 2023-01-27 18:26:39 | 2 | 42,516 | Super Kai - Kazuya Ito |
75,261,937 | 7,938,295 | How Can I Display Multiple Models In a Django ListView? | <p>I am trying to display several models via a ListView. After some research...I have determined that I can do something like...</p>
<pre><code>class MultiModelListView(LoginRequiredMixin,ListView):
model = MultiModel
context_object_name = 'thing_list'
template_name = 'view_my_list.html'
paginate_by =... | <python><django><django-models><django-views><django-templates> | 2023-01-27 18:19:43 | 1 | 1,089 | Steve Smith |
75,261,919 | 7,800,760 | Poetry: because of requirement unavailability need to downgrade python. How to best manage | <p>I am using poetry and had generated an environment with <strong>python 3.11.1</strong>, after which I needed to add the <strong>stanza</strong> package which needs the <strong>torch</strong> package and it turns out that the latter does not exist yet for python 3.11.</p>
<p>I installed <strong>python 3.10</strong> (... | <python><pypi><python-poetry> | 2023-01-27 18:18:32 | 0 | 1,231 | Robert Alexander |
75,261,563 | 18,758,062 | gym 0.21 + stable_baseline3 TypeError: tuple indices must be integers or slices, not str | <p>I'm trying to train a <code>stable_baseline3</code> model on my custom <code>gym</code> environment. The training crashes with a <code>TypeError</code> on the first step.</p>
<pre><code>Using cuda device
Traceback (most recent call last):
File "train_agent.py", line 12, in <module>
model.learn(... | <python><python-3.x><openai-gym><stable-baselines> | 2023-01-27 17:40:07 | 1 | 1,623 | gameveloster |
75,261,514 | 2,635,863 | mutual information for continuous variables with scikit-learn | <p>I have two continuous variables, and would like to compute mutual information between them as a measure of similarity.</p>
<p>I've read some posts suggesting to use the <code>mutual_info_score</code> from <code>scikit-learn</code> but will this work for continuous variables? One SO answer suggested converting the da... | <python><scikit-learn><mutual-information> | 2023-01-27 17:35:49 | 1 | 10,765 | HappyPy |
75,261,409 | 1,296,783 | Use AsyncElasticsearch to perform a cross-index query and get a document | <p>I use an AsyncElasticsearch client instance in order to retrieve a document from an Elasticsearch database:
<code>doc = await client.get(index=some_index, id=some_id)</code></p>
<p>Documentation is <a href="https://elasticsearch-py.readthedocs.io/en/7.x/async.html#elasticsearch.AsyncElasticsearch.get" rel="nofollo... | <python><elasticsearch> | 2023-01-27 17:25:29 | 1 | 798 | yeaaaahhhh..hamf hamf |
75,261,249 | 5,750,741 | How to assign feature weights in XGBClassifier? | <p>I am trying to assign a higher weight to one feature above others. Here is my code.</p>
<pre><code>## Assign weight to High Net Worth feature
cols = list(train_X.columns.values)
# 0 - 1163 --Other Columns
# 1164 --High Net Worth
#Create an array of feature weights
other_col_wt = [1]*1164
high_net_worth_wt = [5]
fe... | <python><machine-learning><scikit-learn><xgboost> | 2023-01-27 17:09:42 | 1 | 1,459 | Piyush |
75,261,178 | 10,034,685 | ModuleNotFoundError even though the Module is present | <p>I am getting a ModuleNotFoundError for a module that exists. I have a <code>__init__.py</code> and imported <code>sys</code> but I am still getting a ModuleNotFoundError error on my django error.</p>
<p>My file structure:</p>
<pre><code>|-my_app
|-folder1
|-__init__.py
|-calc.py
|-folder2
|-__i... | <python><django><module><sys><modulenotfounderror> | 2023-01-27 17:02:49 | 1 | 1,397 | nb_nb_nb |
75,261,056 | 15,500,727 | storing output of a for loop that contains multiple columns in a list | <p>I have the following dataframe:</p>
<pre><code>data = {'id':[1,1,2,2,2,3,3,3],
'var':[10,12,8,11,13,14,15,16],
'ave':[2,2,1,4,3,5,6,8],
'age': [10,10,13,13,20,20,20,11],
'weight':[2.5,1.1,2.1,2.2,3.5,3.5,4.2,1.3],
'con': [3.1,2... | <python><for-loop> | 2023-01-27 16:51:15 | 1 | 485 | mehmo |
75,260,876 | 13,494,917 | Method to turn on Blob Trigger for only a short amount of time | <p>So, I have this Function App with a Blob Trigger, however I don't need it to be polling for new blobs all the time. I'm expecting new files to be found in a container only once a day, and I know at what time I expect those files to be found. What's the best method to approach this?</p>
<p>Here are the questions I ha... | <python><pandas><azure><azure-functions> | 2023-01-27 16:34:25 | 2 | 687 | BlakeB9 |
75,260,541 | 8,372,455 | how to make a stacked keras LSTM | <p>My Tensorflow non-stacked LSTM model code works well for this:</p>
<pre><code># reshape input to be [samples, time steps, features]
trainX = np.reshape(trainX, (trainX.shape[0], 1, trainX.shape[1]))
testX = np.reshape(testX, (testX.shape[0], 1, testX.shape[1]))
# create and fit the LSTM network
model = Sequential()... | <python><tensorflow><machine-learning><lstm><tf.keras> | 2023-01-27 16:03:31 | 0 | 3,564 | bbartling |
75,260,516 | 3,666,302 | How to pass 2D attention mask to HuggingFace BertModel? | <p>I would like to pass a directional attention mask to <code>BertModel.forward</code>, so that I can control which surrounding tokens each token can see during self-attention. This matrix would have to be 2D.</p>
<p>Here is an example with three input ids, where the first two tokens cannot attend to the last one. But ... | <python><pytorch><huggingface-transformers> | 2023-01-27 16:01:01 | 3 | 2,950 | TomTom |
75,260,428 | 2,558,671 | Use an opengis xsd to validate an xml | <p>I am trying to use an xsd downloaded from opengis to validate an xml.</p>
<p>I downloaded the xsd files from <a href="http://schemas.opengis.net/iso/19139/" rel="nofollow noreferrer">http://schemas.opengis.net/iso/19139/</a> (version <code>20060504</code>).</p>
<p>I wanted to load the xsd I need (<a href="http://sch... | <python><xml><lxml><xmllint><opengis> | 2023-01-27 15:54:17 | 1 | 1,503 | Marco |
75,260,057 | 6,283,849 | Async upload with Python Swift client from FastAPI | <p>I am trying to upload files asynchronously to an OpenStack object storage using the Python Swift client. It seems the <code>put_object()</code> method from the Swift client is not async, so although I am running it in an async loop, the loop seems to execute sequentially and it is particularly slow. Note this code i... | <python><asynchronous><upload><fastapi><openstack> | 2023-01-27 15:19:36 | 0 | 6,421 | Alexis.Rolland |
75,260,050 | 15,500,727 | how to use arithmetic operations in groupby function and assign the result to existed dataframe in pandas | <p>suppose I have following dataframe:</p>
<pre><code>data = {'id':[1,1,2,2,2,3,3,3],
'var':[10,12,8,11,13,14,15,16],
'ave':[2,2,1,4,3,5,6,8]}
df = pd.DataFrame(data)
</code></pre>
<p>I am trying to have the operation, <code>con = var*((ave)/sum(ave))</code>, based on each <code>id</... | <python><pandas> | 2023-01-27 15:18:50 | 1 | 485 | mehmo |
75,260,046 | 19,009,577 | Why does trying to add a row to a dataframe yield the error of the truth value of the dataframe being ambiguous | <p>I have some testing code as shown below:</p>
<pre><code>res = pd.DataFrame(columns=[0, 1, 2, 3, 4])
res.loc[len(res)] = pd.DataFrame([5, 6, 7, 8, 9])
</code></pre>
<p>But it causes this error to be shown:</p>
<p>ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.al... | <python><pandas><dataframe> | 2023-01-27 15:18:19 | 1 | 397 | TheRavenSpectre |
75,259,864 | 9,489,014 | APScheduler: Fix references to changed methods in Refactor, renamed or moved modules | <p>I've hada project in python3.7 for a while with a PostgreSQL database and APScheduler 3.X. I'm using a <em>SQLAlchemyJobStore</em> and have several types of jobs configured, both as cron/interval and as single time events.</p>
<p>I had to refactor the code in order to improve the structure and dockerize in a simple... | <python><refactoring><apscheduler> | 2023-01-27 15:01:02 | 1 | 310 | Manu Sisko |
75,259,827 | 2,913,139 | pandas df explode and implode to remove specific dict from the list | <p>I have pandas dataframe with multiple columns. On the the column called <code>request_headers</code> is in a format of list of dictionaries, example:</p>
<pre><code>[{"name": "name1", "value": "value1"}, {"name": "name2", "value": "value2&quo... | <python><pandas> | 2023-01-27 14:58:10 | 3 | 617 | user2913139 |
75,259,760 | 3,719,713 | Annotate a tuple containing an NDArray | <p>I am trying to annotate a function that returns a tuple: <code>tuple[NDArray[Any, Int32 | Float32], dict[str, Any]]:</code> using <code>nptyping</code> for NDArray and <code>typing</code> for other python objects. Here is some code:</p>
<pre><code>from nptyping import NDArray, UInt8, Int32, Float32, Shape, Bool
impo... | <python><numpy><python-typing> | 2023-01-27 14:53:38 | 1 | 1,208 | diegus |
75,259,732 | 553,725 | Error Saving Data to Postgres with Flask / SQLAlchemy | <p>I have a very simple Flask application with a user model. The model looks like this:</p>
<pre><code>class User(db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
phone_number = db.Column(db.String, nullable=False)
# One-to-many relationship between us... | <python><postgresql><sqlalchemy> | 2023-01-27 14:51:07 | 1 | 3,539 | dshipper |
75,259,575 | 17,696,880 | Match words using this regex pattern, only if these words do not appear within a list of substrings | <pre class="lang-py prettyprint-override"><code>import re
input_text = "a áshgdhSdah saasas a corrEr, assasass a saltó sasass a sdssaa" #example
list_verbs_in_this_input = ["serías", "serían", "sería", "ser", "es", "corré", "corrió", &quo... | <python><regex> | 2023-01-27 14:38:13 | 1 | 875 | Matt095 |
75,259,548 | 17,654,424 | How to solve "ModuleNotFoundError: No module named 'djoser'"? | <p>I have installed <code>djoser</code> in my Django project, however, for some reason, it does not find <code>djoser</code> and throws this error:</p>
<blockquote>
<p>ModuleNotFoundError: No module named 'djoser'</p>
</blockquote>
<p>You can see <code>djoser</code> is in my <code>settings.py</code> <code>INSTALLED_APP... | <python><django><modulenotfounderror><djoser> | 2023-01-27 14:35:52 | 5 | 651 | Simao |
75,259,400 | 1,497,418 | Show progress over long sql execute command in python | <p>I created a python script that opens a large SQL file (+50k rows) with inserts onto a table.</p>
<p>The code runs fine, but takes hours, and I was wondering if I could display a progress bar (tqdm doesnt seem to work on this scenario) or just show the "passing time"</p>
<p>Code:</p>
<pre><code>def runScrip... | <python><tqdm> | 2023-01-27 14:24:20 | 1 | 2,578 | Walucas |
75,259,347 | 13,359,498 | TypeError: 'History' object is not callable | <p>I am trying to implement saliency_map. I am using DenseNet121 and I fit the model.
cose snippet:</p>
<pre><code>for train_index, val_index in skf.split(X_train, y_train):
X_train_fold, X_val_fold = X_train[train_index], X_train[val_index]
y_train_fold, y_val_fold = y_train[train_index], y_train[val_index]
... | <python><tensorflow><keras><conv-neural-network><visualization> | 2023-01-27 14:19:24 | 2 | 578 | Rezuana Haque |
75,259,296 | 1,001,224 | aggregate by value and count, distinct array | <p>Let's say i have this list of tuples</p>
<pre><code>[
('r', 'p', ['A', 'B']),
('r', 'f', ['A']),
('r', 'e', ['A']),
('r', 'p', ['A']),
('r', 'f', ['B']),
('r', 'p', ['B']),
('r', 'e', ['B']),
('r', 'c', ['A'])
]
</code></pre>
<p>Need to return a list of tuples that aggregated (group by) by the second value in the tu... | <python><arrays><tuples> | 2023-01-27 14:14:18 | 4 | 18,054 | lolo |
75,259,250 | 5,640,517 | Selenium finding link by text when text-transform present | <p>I have this HTML</p>
<pre class="lang-html prettyprint-override"><code><div class="tabsAction">
<a class="butAction" href="" title="" data-original-title="">Validar</a>
<a class="butAction" href="" title="" data-... | <python><selenium> | 2023-01-27 14:10:45 | 2 | 1,601 | Daviid |
75,259,240 | 19,336,534 | Different results for Keras recall and custom recall | <p>I am implementing a model for time series prediction. Given a multi-attribute input of N steps i output vectors of size 5 containing binary variables.<br />
For example an output vector may be : [1 0 0 1 0]. This is compared against a true one.<br />
I also have a batch size of 32.<br />
Base on this i calculate rec... | <python><python-3.x><tensorflow><keras><tensorflow2.0> | 2023-01-27 14:09:49 | 0 | 551 | Los |
75,259,112 | 1,518,480 | Curve translation in Python does not reach expected value | <p>Suppose I have two curves, f(x) and g(x), and I want to evaluate if g(x) is a translation of f(x).
I used Sympy Curve to do the job with the function <code>translate</code>. However, I need help to reach the correct result. Consider the two functions:</p>
<p>f(x) = -x^2 and g(x) = -(x+5)^2 + 8</p>
<p>Notice that g i... | <python><math><sympy> | 2023-01-27 13:57:50 | 2 | 491 | marcelo.guedes |
75,259,082 | 6,176,347 | Python conflict between 2 libraries: requests.get() takes 1 positional argument but 2 were given | <p>I'm using Home Assistant and I'm trying to fix this GitHub issue: <a href="https://github.com/home-assistant/core/issues/75739" rel="nofollow noreferrer">https://github.com/home-assistant/core/issues/75739</a></p>
<p>In short, what happens is that 2 plugins (<code>toshiba-ac</code> and <code>solaredge</code>) confli... | <python><home-assistant> | 2023-01-27 13:55:19 | 0 | 809 | Bart |
75,259,016 | 12,436,050 | Join pandas dataframes using regex on a column using Python 3 | <p>I have two pandas dataframe df1 and df2. I would like to join the two dataframes using regex on column 'CODE'.</p>
<pre><code>df1
STR CODE
Nonrheumatic aortic valve disorders I35
Glaucoma suspect H40.0
df2
STR CODE
Nonrheumatic aor... | <python><pandas><dataframe> | 2023-01-27 13:50:10 | 2 | 1,495 | rshar |
75,258,840 | 2,013,056 | AttributeError: 'list' object has no attribute 'find_element' - Selenium driver | <p>I am in the process of rewriting this old pyton script (<a href="https://github.com/muvvasandeep/BuGL/blob/master/Scripts/DataExtraction.py" rel="nofollow noreferrer">https://github.com/muvvasandeep/BuGL/blob/master/Scripts/DataExtraction.py</a>) which used older version of Selenium. The aim of this script is to ext... | <python><python-3.x><selenium><selenium-webdriver><selenium-chromedriver> | 2023-01-27 13:36:36 | 2 | 649 | Mano Haran |
75,258,549 | 1,768,474 | Catch-all field for unserialisable data of serializer | <p>I have a route where meta-data can be POSTed. If known fields are POSTed, I would like to store them in a structured manner in my DB, only storing unknown fields or fields that fail validation in a <code>JSONField</code>.</p>
<p>Let's assume my model to be:</p>
<pre><code># models.py
from django.db import models
c... | <python><django><django-rest-framework><django-serializer> | 2023-01-27 13:08:24 | 3 | 557 | finngu |
75,258,442 | 6,213,883 | Using mysql-connector-python, how to insert a "complicated" (with delimiter instruction) trigger to MariaDB? | <p>I wish to create a trigger in MariaDB 5.5.68.</p>
<p>Base on <a href="https://mariadb.com/kb/en/trigger-overview/#more-complex-triggers" rel="nofollow noreferrer">this official example</a>, I built this query:</p>
<pre class="lang-py prettyprint-override"><code>query = ("""
DELIMITER //
create trigger... | <python><mariadb> | 2023-01-27 12:57:22 | 1 | 3,040 | Itération 122442 |
75,258,233 | 9,261,745 | Pyspark dataframe to insert an array of array's element to each row | <p>I want to put this <code>arrays = [[1, 2, 3], [4, 5, 6]]</code> into another column with its array element.</p>
<pre><code>df = spark.createDataFrame([(1, "foo"), (2, "bar")], ["id", "name"])
+---+----+
| id|name|
+---+----+
| 1| foo|
| 2| bar|
+---+----+
</code></pre>
<p>Th... | <python><dataframe><apache-spark><pyspark> | 2023-01-27 12:40:00 | 1 | 457 | Youshikyou |
75,258,017 | 3,204,212 | How does Pylance want me to compare numbers if int and literals can't be compared? | <p>The expression</p>
<pre><code>random.randint(1, 10) == 5
</code></pre>
<p>causes my linter to report the error 'Operator "==" not supported for types "int" and "Literal[0]'.</p>
<p>If I try to cast the comparison to an int/int one, like</p>
<pre><code>random.randint(1, 10) == int(5)
</code><... | <python><pylance> | 2023-01-27 12:19:32 | 0 | 2,480 | GreenTriangle |
75,257,959 | 17,729,272 | How to generate templated Airflow DAGs using Jinja | <p>I'm bit new to Airflow and was exploring creation of multiple DAGs that have more or less same code from a template instead of creating them as individual DAGs which introduces maintenance overhead. I found <a href="https://medium.com/@alimasri1991/auto-generating-airflow-dags-3c8c4aa6ad11" rel="nofollow noreferrer"... | <python><airflow><jinja2><templating><mwaa> | 2023-01-27 12:14:41 | 1 | 529 | ACL |
75,257,768 | 5,986,907 | How to create a table with schema in SQLModel? | <p>I want to create a table with schema <code>"fooschema"</code> and name <code>"footable"</code>. Based on <a href="https://github.com/tiangolo/sqlmodel/issues/20" rel="nofollow noreferrer">this GitHub issue</a> and to some extent the docs, I tried</p>
<pre><code>fooMetadata = MetaData(schema="... | <python><database><postgresql><schema><sqlmodel> | 2023-01-27 11:55:34 | 1 | 8,082 | joel |
75,257,722 | 16,719,690 | How can I correctly type-hint a function that uses numpy array operations on either numeric or array-like inputs? | <p>I am trying to learn about type hinting and while it all seems very clear for when a function argument takes on a well-defined data type, I am stuck with how to handle when the argument could be a numeric value OR a numpy array:</p>
<pre><code>import numpy as np
def square(x: np.ndarray):
return x**2
num = 9
p... | <python><numpy><type-hinting> | 2023-01-27 11:51:08 | 0 | 357 | crabulus_maximus |
75,257,677 | 10,694,247 | AWS Lambda function with DynamoDB giving schema Error | <p>I have a below <code>aws lambda</code> code which is basically for ONTAP FileSystem monitoring and works if I do not integrate that to Dynamodb, while using this for now its giving me an error <code>element does not match the schema</code>.</p>
<p>Being a First time user of DynamoDB, i would love you seek some guida... | <python><amazon-web-services><aws-lambda><amazon-dynamodb> | 2023-01-27 11:46:43 | 2 | 488 | user2023 |
75,257,408 | 9,609,901 | Setting verbose to 0 doesn't work as expected | <p>I have developed a Deep Q-Learning agent. I have used <code>verbose=0</code> in <code>model.fit()</code> function and still getting the following line as output:</p>
<pre><code>1/1 [==============================] - 0s 12ms/step
</code></pre>
<p>here's how i build the model:</p>
<pre><code>def build_model(self):
... | <python><keras><deep-learning> | 2023-01-27 11:19:20 | 1 | 568 | Don Coder |
75,257,369 | 11,501,160 | PyPDF2 paper size manipulation | <p>I am using PyPDF2 to take an input PDF of any paper size and convert it to a PDF of A4 size with the input PDF scaled and fit in the centre of the output pdf.</p>
<p>Here's an example of an input (convert to pdf with imagemagick <code>convert image.png input.pdf</code>), which can be of any dimensions:
<a href="http... | <python><pypdf> | 2023-01-27 11:15:41 | 1 | 305 | Zain Khaishagi |
75,257,103 | 7,959,614 | Find all elements (even outside viewport) using Selenium | <p>Its my understanding that when the <code>find_elements</code>-method is called on a <code>selenium.webdriver</code>-instance, it returns a reference of all the elements in the DOM that matches with the provided locator.</p>
<p>When I run the following code I only get <30 elements whereas there are many more on th... | <python><selenium> | 2023-01-27 10:52:32 | 1 | 406 | HJA24 |
75,257,052 | 11,814,996 | Getting Unique Values and their Following Pairs from a List of Tuples | <p>I have a list of tuples like this:</p>
<pre><code>[
('a', 'AA'), # pair 1
('d', 'AA'), # pair 2
('d', 'a'), # pair 3
('d', 'EE'), # pair 4
('b', 'BB'), # pair 5
('b', 'CC'), # pair 6
('b', 'DD'), # pair 7
('c', 'BB'), # pair 8
('c', 'CC'), # pair 9
('c', 'DD'), # pair 10
... | <python><python-3.x> | 2023-01-27 10:48:37 | 2 | 3,172 | Naveen Reddy Marthala |
75,256,900 | 13,328,625 | Word2Vec empty word not in vocabulary | <p>I'm currently required to work on a multilingual text classification model where I have to classify whether two sentences in two languages are semantically similar. I'm also required to use Word2Vec for word embedding.</p>
<p>I am able to generate the word embedding using Word2Vec, however, when I'm trying to conver... | <python><word2vec> | 2023-01-27 10:34:55 | 1 | 478 | InvalidHop |
75,256,768 | 3,793,935 | Python Sphinx Module Not Found | <p>I have a subproject that I would like to document with python sphinx.
It is structured this way:
<a href="https://i.sstatic.net/b0EBo.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/b0EBo.png" alt="enter image description here" /></a></p>
<p>The documentation from the extraction_model went without any... | <python><python-sphinx><autodoc> | 2023-01-27 10:24:03 | 1 | 499 | user3793935 |
75,256,584 | 2,074,794 | Reuse function as pytest fixture | <p>I have a function in my code that is being used by fastapi to provide a db session to the endpoints:</p>
<pre><code>def get_db() -> Generator[Session, None, None]:
try:
db = SessionLocal()
yield db
finally:
db.close()
</code></pre>
<p>I want to use the same function as a pytest fix... | <python><pytest><python-decorators><fixtures> | 2023-01-27 10:06:27 | 1 | 2,156 | kaveh |
75,256,580 | 3,336,412 | check if a bytes-array is a hex-literal | <p>From an API I receive following types of bytes-array:</p>
<pre><code>b'2021:09:30 08:28:24'
b'\x01\x02\x03\x00'
</code></pre>
<p>I know how to get the values for them, like for the first one with <code>value.decode()</code> and for the second one with <code>''.join([str(c) for c in value])</code></p>
<p>the problem... | <python><string><decoding> | 2023-01-27 10:06:10 | 2 | 5,974 | Matthias Burger |
75,256,287 | 19,363,912 | Create a link between 2 classes | <p>Is there any way to connect 2 classes (without merging them in 1) and thus avoiding repetition under statement <code>if a:</code> in <code>class Z</code>?</p>
<pre><code>class A:
def __init__(self, a):
self.a = a
self.b = self.a + self.a
class Z:
def __init__(self, z, a=None):
self.z... | <python><class><composition><delegation> | 2023-01-27 09:39:05 | 2 | 447 | aeiou |
75,256,216 | 12,990,185 | Python - how to add "pipe" in exec_cmd method | <p>I have my python function which works perfectly in both windows and linux, when executing the command and processing the output.</p>
<pre><code>def exec_cmd(cmd, fail=True):
try:
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
return output
except subprocess.CalledProcessErro... | <python><python-3.x> | 2023-01-27 09:31:11 | 0 | 1,260 | vel |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.