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 ⌀ |
|---|---|---|---|---|---|---|---|---|
76,325,578 | 1,736,407 | ValueError: Protocol message OrderedJob has no "template" field | <p>I'm writing a Google Cloud Function that invokes a Dataproc Workflow defined in a YAML file on cloud storage.</p>
<p>When testing the invocation, the function crashes immediately with the following stack trace:</p>
<pre><code>"Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/pyt... | <python><google-cloud-functions><google-cloud-dataproc><google-workflows> | 2023-05-24 16:19:55 | 1 | 2,220 | Cam |
76,325,424 | 9,757,174 | ImportError: cannot import name 'resource_loader' from partially initialized module 'tensorflow._api.v2.compat.v1' | <p>I am building a chatbot using <code>rasa</code>. When I try to run <code>rasa train</code>, I get the following error.</p>
<pre><code>from tensorflow._api.v2.compat.v1 import resource_loader
ImportError: cannot import name 'resource_loader' from partially initialized module 'tensorflow._api.v2.compat.v1'
</code></p... | <python><tensorflow><rasa> | 2023-05-24 15:59:51 | 1 | 1,086 | Prakhar Rathi |
76,325,336 | 7,327,257 | Remove files with a string in a bucket google cloud storage in python | <p>I'm working with google cloud storage and have several files uploaded to a bucket with similar names. Each file has the following format: <code>company_tile_lc_date1_today.tif</code>, where <code>today</code> is the date when the file was created and uploaded to the bucket. I also have files with this format: <code>... | <python><google-cloud-storage> | 2023-05-24 15:48:22 | 0 | 357 | M. Merida-Floriano |
76,325,304 | 298,209 | Waiting on asyncio futures outside asyncio.run() | <p>I came across this pattern in some code base and it's breaking my mental model of how things work in asyncio. We have this function that awaits on a subset of futures and returns another subset that takes much longer to finish. It then waits for the second subset outside <code>asyncio.run()</code>. I'm not sure I un... | <python><python-asyncio> | 2023-05-24 15:44:33 | 0 | 5,580 | Milad |
76,325,202 | 3,611,472 | How to solve compatibility with old pandas and tensorflow on M1 chip | <p>I am working with a MacBook Pro M1.</p>
<p>I have to run a code that was written several years ago and relies on python 3.6, pandas 0.20.3 and numpy 1.17.3.</p>
<p>On top of these packages, I should also use TensorFlow. Here's the problem. Since I am running the code on a Mac M1, I need to use <code>tensorflow-macos... | <python><pandas><tensorflow><apple-m1> | 2023-05-24 15:33:17 | 1 | 443 | apt45 |
76,325,145 | 10,755,032 | NotFittedError: This RandomForestRegressor instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator | <p>I have taken a look at this: <a href="https://stackoverflow.com/questions/51397611/randomforestclassifier-instance-not-fitted-yet-call-fit-with-appropriate-argu">RandomForestClassifier instance not fitted yet. Call 'fit' with appropriate arguments before using this method</a> not helped.</p>
<p>I was running... | <python><machine-learning><scikit-learn><random-forest> | 2023-05-24 15:26:44 | 1 | 1,753 | Karthik Bhandary |
76,325,091 | 7,185,934 | pyproject.toml setuptools: edit user's .bashrc file | <p>I am writing a Python package that has an entrypoint (cli) script using a pyproject.toml file that builds with setuptools.</p>
<p>I'm installing this package locally with <code>pip install --user .</code>
--user is necessary for me because in my environment only my user's dir (/home) is preserved over sessions.</p>
... | <python><setuptools><pyproject.toml> | 2023-05-24 15:20:13 | 1 | 815 | David Skarbrevik |
76,324,972 | 1,310,540 | Error while accessing local file using selenium webdriver | <p>I am having an issue which I tried to reproduce locally.</p>
<p>I have an XML file and when I open it <code>chrome webdriver</code> with url like: <code>http://localhost:63342/Testing_Prj/EXPORT.xml</code> the <strong>driver.page_source</strong> working fine. Alternately if I open the same file using url like: <code... | <python><xml><selenium-webdriver> | 2023-05-24 15:06:08 | 1 | 931 | Mehmood |
76,324,839 | 5,924,264 | unbound method __init__() error in unit tests but not in regular executions | <p>I got this:</p>
<pre><code>
DataBaseStorage.__init__(
> self, key=key, sz=sz,
)
E TypeError: unbound method __init__() must be called with DataBaseStorage instance as first argument (got BaseStorage instance instead)
path/to/file/DataBase.py:80: TypeError
</code></pre>
<p>The traceb... | <python><python-2.7><unit-testing><inheritance> | 2023-05-24 14:53:08 | 0 | 2,502 | roulette01 |
76,324,830 | 17,487,457 | dataframe column's aggregate based on simple majority | <p>I have a <code>dataframe</code> from my model's prediction similar to the one below:</p>
<pre class="lang-py prettyprint-override"><code>df = pd.DataFrame({
'trip-id': [8,8,8,8,8,8,8,8,4,4,4,4,4,4,4,4,4,4,4,4],
'segment-id': [1,1,1,1,1,1,1,1,0,0,0,0,0,0,5,5,5,5,5,5],
'true_label': [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, ... | <python><pandas><dataframe> | 2023-05-24 14:52:02 | 1 | 305 | Amina Umar |
76,324,824 | 2,283,347 | How to return existing matching record for Django CreateView | <p>I use a regular <code>generic.edit.CreateView</code> of <code>Django</code> to create an object according to user input. The <code>MyModel</code> has an <code>UniqueConstrait</code> so the creation would fail if the new object happens to match an existing one.</p>
<p>However, instead of telling users that creation f... | <python><django><django-class-based-views> | 2023-05-24 14:51:39 | 1 | 799 | user2283347 |
76,324,705 | 1,802,693 | Generating classes in python by using an exisiting one's constructor | <p>I want to generate some classes, which automatically sets an existing one <code>FieldDescriptor</code> by using the values from enum.</p>
<p>I want to generate the following classes without writing them:</p>
<ul>
<li><code>GEN_STING</code>, <code>GEN_BIGINT</code>, <code>GEN_FLOAT</code></li>
</ul>
<p>For some reaso... | <python><metaprogramming><dynamically-generated> | 2023-05-24 14:37:00 | 2 | 1,729 | elaspog |
76,324,700 | 3,817,456 | How to calculate current time in different timezone correctly in Python | <p>I was trying to calculate the current time in NYC (EST time aka Eastern Daylight time or GMT-4) given current time in Israel (Israel daylight time, currently GMT+3) where I'm currently located. So right now Israel is 7 hrs ahead of NYC, but I get an 8 hr difference, with NYC coming out an hour earlier than it real... | <python><datetime><timezone><dst><pytz> | 2023-05-24 14:36:33 | 1 | 6,150 | jeremy_rutman |
76,324,695 | 3,371,250 | How to create a tree structure from a logical expression? | <p>I want to parse a logical expression like the following:</p>
<pre><code>(f = '1' OR f = '2') AND (s = '3' OR s = '4' OR s = '5') AND (t = '6')
</code></pre>
<p>What I need, is a representation of this logical expression in the form of a expression tree. In the end I want to be able to create a JSON representation of... | <python><regex><parsing><expression-trees><python-re> | 2023-05-24 14:36:04 | 2 | 571 | Ipsider |
76,324,628 | 3,438,507 | How to sort a list of dictionaries by a list that can contain duplicate values? | <p><strong>Context:</strong><br />
In Python 3.9 sorting a list of most objects by a second list is easy, even if duplicates are present:</p>
<pre><code>>>> sorted(zip([5, 5, 3, 2, 1], ['z', 'y', 'x', 'w', 'x']))
[(1, 'x'), (2, 'w'), (3, 'x'), (5, 'y'), (5, 'z')]
</code></pre>
<p>If this list to be sorted cont... | <python><list><dictionary><sorting> | 2023-05-24 14:28:27 | 3 | 1,155 | M.G.Poirot |
76,324,479 | 2,986,042 | How to properly use subprocess.Popen thread's in python? | <p>I am writing a python script which will execute some another script from <code>bash</code> terminals. I need <code>two bash terminal</code> and execute some script in that bash terminal one by one. After executing the script, I will read the out put messages to a <code>Tkinter text area</code>. I have designed simp... | <python><stdin><popen> | 2023-05-24 14:09:12 | 1 | 1,300 | user2986042 |
76,324,393 | 1,934,212 | Heatmap based on DataFrame | <p>The Dataframe</p>
<pre><code>import pandas as pd
import plotly.express as px
df = pd.DataFrame({"A":[1,2,3],"B":[4,5,6]})
print(df)
A B
0 1 4
1 2 5
2 3 6
</code></pre>
<p>transformed into a heatmap using</p>
<pre><code>fig = px.density_heatmap(df)
fig.show()
</code></pre>
<p>results i... | <python><pandas><plotly> | 2023-05-24 14:03:08 | 2 | 9,735 | Oblomov |
76,324,263 | 11,540,781 | Pandas/Dask read_parquet columns case insensitive | <p>Can i have a <em>columns</em> argument on pd.read_parquet() that filters columns, but is case insensitive, I have files with the same columns, but some are camel case, some are all capital, some are lowercase, it is a mess, and i can't read all columns and filter afterwards, and sometimes I have to read directly to ... | <python><pandas><dask><parquet><dask-dataframe> | 2023-05-24 13:50:19 | 2 | 343 | Ramon Griffo |
76,324,247 | 6,195,489 | get sqlalchemy with apscheduler multithreading to work | <p>I have a list of jobs I am adding to an <a href="https://apscheduler.readthedocs.io/en/3.x/" rel="nofollow noreferrer">apscheduler</a> BlockingScheduler with a ThreadPoolExecutor number the same size as the number of jobs.</p>
<p>The jobs I am adding are using sqlalchemy and interacting with the same database, but i... | <python><sqlite><sqlalchemy><apscheduler> | 2023-05-24 13:48:40 | 1 | 849 | abinitio |
76,324,028 | 19,325,656 | Request.endpoint is none when bearer token is present | <p>I have app where before request i check if JWT token is present in request. If the token is present I check for the user and if I get the user I want to redirect user to URL that he wanted to access if token isn't present redirect user to login page.</p>
<p>The problem is when I'm trying to redirect the request.endp... | <python><flask><flask-jwt-extended><flask-jwt> | 2023-05-24 13:22:26 | 0 | 471 | rafaelHTML |
76,323,649 | 11,466,416 | PyBind11 - compilation errors from several library files | <p>recently I created code in c++ that I would like to use in Python, so I opted for PyBind11 as it seemed to be straight forward. As I never worked with this tool, I first wanted to understand and try out the basic example given in the documentation:</p>
<p><a href="https://pybind11.readthedocs.io/en/latest/basics.htm... | <python><c++><compiler-errors><pybind11> | 2023-05-24 12:40:36 | 1 | 456 | Blindschleiche |
76,323,628 | 13,506,329 | Inconsistent behaviour between NumPy floats and integers | <p>Consider the following code</p>
<pre><code># Create the 5x3 array
array1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [101, 110, 120], [13, 14, 15]])
# Create the 8x3 array
array2 = np.array([[1, 2, 3], [7, 8, 9], [4, 5, 6], [16, 17, 18], [19, 20, 21], [10, 11, 12], [22, 23, 24], [13, 14, 15]])
# Check equality o... | <python><python-3.x><numpy><vectorization><numpy-ndarray> | 2023-05-24 12:37:38 | 1 | 388 | Lihka_nonem |
76,323,607 | 9,039,975 | Django ORM : Filter to get the users whose birthday week is in n days | <p>I am trying to make a django query which is supposed to gave me the users whose birthday week is in n days.</p>
<p>I already tried to use the __week operator but it's not working as expected :</p>
<pre><code> now = timezone.now().date()
first_day_of_next_week = (now + timedelta(days=(7 - now.weekday())))
... | <python><django><datetime><orm> | 2023-05-24 12:34:44 | 2 | 875 | Artory |
76,323,573 | 970,872 | reading escaped sequences from sys.stdin, bytes after escape are delayed until the next keystroke using select | <p>I'm trying to process keystrokes in linux so I can handle arrow keys as well as normal alphnumeric etc keys.
This potentially simple approach using select and stdin delivers all the keys, but after pressing (for example) uparrow, I don't get the extra chars after escape until I press another key.</p>
<p>The extra ch... | <python><linux><keyboard> | 2023-05-24 12:30:17 | 1 | 557 | pootle |
76,323,478 | 5,340,217 | Numpy indexing behavior with unexpected dimension ordering | <pre class="lang-py prettyprint-override"><code>>> np.arange(24).reshape(2,3,4)[0,:,[2,3]].shape
(2,3)
>> np.arange(24).reshape(2,3,4)[0,[1,2],:].shape
(2,4)
</code></pre>
<p>I get the second one, but why the first one is not <code>(3,2)</code>?</p>
<p>In the first case, the first two indices (<code>0</code... | <python><numpy> | 2023-05-24 12:21:10 | 0 | 422 | Brainor |
76,323,287 | 8,477,566 | Is it possible to stack multiple transformations/functions in PyTorch into a single function? | <p>Is it possible to stack multiple transformations/functions in PyTorch into a single function? I'm ideally looking for something like this (possibly with more care taken over tensor shapes):</p>
<pre class="lang-py prettyprint-override"><code>import torch
f_stack = torch.stack([lambda x: x+1, lambda x: x*2, lambda x... | <python><function><deep-learning><pytorch><vectorization> | 2023-05-24 11:59:54 | 1 | 1,950 | Jake Levi |
76,323,281 | 8,671,089 | unable to write on kafka topic created on kafka container | <p>I am writing integration tests and created kafka topic using docker command <code>docker exec kafka-broker kafka-topics.sh --create --bootstrap-server localhost:9093 --partitions 1 --replication-factor 1 --topic test-topic</code> in github workflow, Topic is created successfully. Using kafka topic in testcase to wri... | <python><docker><pyspark><apache-kafka> | 2023-05-24 11:59:26 | 2 | 683 | Panda |
76,323,278 | 20,770,190 | StaleDataError: DELETE statement on table 'event_services' expected to delete 2 row(s); Only 3 were matched | <p>I have a model named <code>Event</code>, and a model named <code>ServicePartner</code>, they have many-to-many relationship with each other with a secondary join and secondary table named <code>EventServices</code>. Now, in the <code>event_services</code> table, I have three rows related to a specific <code>event</c... | <python><sqlalchemy> | 2023-05-24 11:59:16 | 1 | 301 | Benjamin Geoffrey |
76,323,081 | 577,647 | PEP8 between specific lines | <p>I have some huge files in my codebase which have many pep8 related issues.</p>
<p>Is there any way to analyze specific lines with pep8</p>
<pre><code>pep8 input /path/to/my-code.py --lines=100-200
</code></pre>
<p>So that I can analyze specific part of the code?</p>
| <python><django><pep8> | 2023-05-24 11:33:39 | 1 | 2,888 | tolga |
76,322,954 | 2,137,570 | python - Beautiful soup - get specific value in html not standard tag | <p>Fairly new to beautiful soup. Trying to parse this tag</p>
<p>html</p>
<pre><code><score-bill scoreA="86" audiencestate="upright" data-qa="score-panel" data-scoresmanager="scorebill:scoreAction" id="scoreboard" mediatype="assetseries" rating=""... | <python><beautifulsoup> | 2023-05-24 11:16:22 | 1 | 5,998 | Lacer |
76,322,753 | 7,424,495 | Disable google cloud authentication python when mocking google.cloud.storage | <p>With the following mock of google cloud storage</p>
<pre class="lang-py prettyprint-override"><code>from google.cloud import storage
class MockBlob:
def download_as_string(self) -> bytes:
return bytes("\n".join(INPUT_IDS), "utf-8")
class MockBucket:
def get_blob(self, path:... | <python><google-cloud-storage> | 2023-05-24 10:55:32 | 1 | 1,751 | S.MC. |
76,322,694 | 12,875,947 | How to update multiple dictionary key-value without using for loop | <p>I have a list of dictionaries with the same keys but different values.
Example:</p>
<pre><code>[{ 'Price' : 100, 'Quantity' : 3 }, { 'Price' : 200, 'Quantity' : 5 }]
</code></pre>
<p>Is there a way to update the value of a particular key in all dictionaries in one go without using for loop?</p>
<p>That is, is there ... | <python><django><pandas><dataframe><numpy> | 2023-05-24 10:48:39 | 2 | 1,886 | Narendra Vishwakarma |
76,322,597 | 1,506,850 | prevent AssertionError: daemonic processes are not allowed to have children | <p>I am running stuff using <code>Pool</code>/<code>multiprocessing</code>.
Whenever I call Pool again (nested) within one of the child processes of the main process, this error is raised?</p>
<pre><code>prevent multiprocessing gives AssertionError: daemonic processes are not allowed to have children
</code></pre>
<p>I... | <python><multiprocessing><pool> | 2023-05-24 10:36:49 | 1 | 5,397 | 00__00__00 |
76,322,534 | 1,714,385 | How to remove trailing rows that contain zero of pandas DataFrame | <p>I have a pandas dataframe with a single column, which ends with some values being zero, like so:</p>
<pre><code>index value
0 4.0
1 34.0
2 -2.0
3 15.0
... ...
96 0.0
97 45
98 0.0
99 0.0
100 0.0
</code></pre>
<p>I would like to strip away the trailing rows that contain the zero value... | <python><pandas> | 2023-05-24 10:28:44 | 4 | 4,417 | Ferdinando Randisi |
76,322,516 | 4,929,646 | Verify Apple's signature | <p>I'm trying to verify a signature according to the <a href="https://developer.apple.com/documentation/storekit/skadnetwork/verifying_an_install-validation_postback#3599761" rel="nofollow noreferrer">documentation</a>. Here is an example:</p>
<pre><code># cryptography==37.0.4
from cryptography.hazmat.primitives import... | <python><cryptography><x509><public-key> | 2023-05-24 10:26:48 | 1 | 11,422 | Danila Ganchar |
76,322,463 | 8,930,395 | How to initialize a global object or variable and reuse it in every FastAPI endpoint? | <p>I am having a class to send notifications. When being initialized, it involves making a connection to a notification server, which is time-consuming. I use a background task in FastAPI to send notifications, as I don't want to delay the response due to the notification. Below is the sample code:</p>
<p><strong>file1... | <python><global-variables><fastapi><background-task><starlette> | 2023-05-24 10:20:42 | 1 | 4,606 | LOrD_ARaGOrN |
76,322,400 | 6,752,358 | Reuse bigquery queryJob as base query to use for further operation | <p>As the title says, I don't know if it is possible to reuse the queryjob obtained by the execution of a query to perform additional SQL operations. Below an example of what I mean</p>
<pre class="lang-py prettyprint-override"><code>from google.cloud import bigquery
client = bigquery.Client()
myquery = "SELECT *... | <python><sql><python-3.x><google-bigquery> | 2023-05-24 10:12:38 | 1 | 359 | lordcenzin |
76,322,383 | 11,452,928 | How Jax use LAX-backend implementation of functions | <p>I need to compute the kron procuts of two arrays and I want to test if doing it using Jax is faster than doing it using Numpy.</p>
<p>Now, in numpy my code there is <code>res = numpy.kron(x1,x2)</code>, in Jax there is <code>jax.numpy.kron(x1,x2)</code> but how can I use it properly?
My doubs are:</p>
<ul>
<li><p>is... | <python><jax> | 2023-05-24 10:10:32 | 1 | 753 | fabianod |
76,322,334 | 10,413,428 | typing.NamedTuple as type annonation for list does not work | <p>I though I could specify a type for the elements of a list as follows:</p>
<pre class="lang-py prettyprint-override"><code>import typing
CustomType = typing.NamedTuple("CustomType", [("one", str), ("two", str)])
def test_function(some_list: list[CustomType]):
print(some_list)
... | <python><python-3.x> | 2023-05-24 10:04:13 | 1 | 405 | sebwr |
76,322,177 | 2,966,197 | streamlit markdown color change not working | <p>My streamlit markdown text is all coming white and I want it to be black. Here is what my markdown code is but it just inputs everything as it is:</p>
<pre><code>st.markdown(
"""
<span style='color:black'>This is First page
You can:
- Say Hi
- Send email
... | <python><streamlit> | 2023-05-24 09:46:12 | 1 | 3,003 | user2966197 |
76,322,147 | 8,219,760 | Overriden `Process.run` does not execute asynchronously | <p>Having subclassed <code>Process.run</code></p>
<pre class="lang-py prettyprint-override"><code>import multiprocessing as mp
import time
DELAY = 2
class NewProcess(mp.get_context().Process):
def run(self) -> None:
# add new kwarg to item[4] slot
old_que = self._args[0]
new_que = mp.Si... | <python><multiprocessing> | 2023-05-24 09:42:41 | 1 | 673 | vahvero |
76,322,128 | 710,955 | PyO3 - How to return enums to python module? | <p>I'm trying to build a Python package from Rust using PyO3. Right now I'm stuck trying to return <code>enums</code> Rust type to Python.</p>
<p>I have a simple enum like so:</p>
<pre class="lang-rust prettyprint-override"><code>pub enum Lang {
Deu,
Eng,
Fra
}
</code></pre>
<p>And in <code>lib.rs</code></p... | <python><rust><enums><pyo3> | 2023-05-24 09:40:12 | 2 | 5,809 | LeMoussel |
76,322,054 | 294,974 | Updating a boolean property in SQLAlchemy(2.x) model while satisfying MyPy | <p>I am trying to update a boolean property in my SQLAlchemy model and I want to make sure MyPy is satisfied with the code as well. However, MyPy is giving me an error when I try to update the property. Here's the error message:</p>
<pre><code>dashing/db/dao/workspace_dao.py:69: error: Incompatible types in assignment
... | <python><sqlalchemy><fastapi><mypy> | 2023-05-24 09:32:10 | 1 | 1,560 | carloe |
76,322,024 | 5,406,764 | Sympy count_ops returning incorrect result? | <p>I'm doing a simple test with sympy (python=3.10, sympy=1.12) and I don't understand why the result seems wrong (results below):</p>
<p>Code:</p>
<pre><code>from sympy import *
x0, x1, x2 = symbols('x0 x1 x2')
print(count_ops(2 * (x0 + x1) * x2, visual=True))
</code></pre>
<p>Result:</p>
<pre><code>Add + 3*MUL
</code... | <python><sympy><symbolic-math><algebra> | 2023-05-24 09:28:22 | 2 | 1,825 | user5406764 |
76,321,982 | 10,992,997 | Issue using poetry to package python code (No file/folder found for package ...) | <p>I have written a number of functions that help to ingest raw data from research device.</p>
<p>There's two groups of functions</p>
<p>Those that help to normalise timestamps</p>
<p>Those that actually read in/reshape the data</p>
<p>I have set the project up in a git repo, and there's two sub directories that contai... | <python><package><python-poetry> | 2023-05-24 09:23:51 | 0 | 581 | KevOMalley743 |
76,321,902 | 3,835,843 | RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C returns error | <p>In the <strong>Dockerfile</strong> it has written like this:</p>
<pre><code>FROM osgeo/gdal:ubuntu-small-3.6.3
RUN apt-get install --no-install-recommends -y gnupg
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C
</code></pre>
<p>While I built, it shows this error:</p>
<pre><code> =>... | <python><docker> | 2023-05-24 09:15:02 | 1 | 6,588 | Arif |
76,321,801 | 8,512,941 | Type hints for lxml.etree._Element | <p>I often work with the <code>lxml</code> and my IDE (PyCharm 2021.2.2) warns me about accessing a protected member of the module in my type hints because many of my function use <code>lxml.etree._Element</code> as inputs or outputs. But as many functions of <code>lxml.etree</code> returns <code>_Element</code> object... | <python><lxml><python-typing> | 2023-05-24 09:03:52 | 0 | 349 | Arlaf |
76,321,764 | 188,331 | How to return some float values with zip() in Python function? TypeError: 'float' object is not iterable | <p>I wrote a simple function that wants to return more than 1 float values at the same time</p>
<pre><code>def test_zip_float():
return zip(1.234, 3.456)
print(test_zip_float())
</code></pre>
<p>It results in:</p>
<blockquote>
<p>TypeError: 'float' object is not iterable</p>
</blockquote>
<p>I can rewrite it as:</... | <python><python-3.x><floating-point><return> | 2023-05-24 08:59:34 | 1 | 54,395 | Raptor |
76,321,503 | 7,791,963 | In Python, how to read and count all values from an Exceel sheet only if the cell has no color? | <p>I have multiple exceel sheets that I am not able to change structure of. Each sheet contains multiple tables of different structures so it's hard to automatically parse it. However, the cells of interest are white cells in all these tables, all other cells such as headers and extra meta data has colored cells.</p>
<... | <python><pandas><excel> | 2023-05-24 08:27:01 | 2 | 697 | Kspr |
76,321,501 | 20,051,041 | How to handle AioHttpClient in Pytest? | <p>I am writing my first test (unit test with Pytest), that contains AioHttpClient with BasicAuth (with username and poassword).
My function's structure:</p>
<pre><code>async def example_function(some parameters):
(...)
try:
synth_url = os.getenv("SYNTH_URL", 'https://...')
async with ... | <python><mocking><pytest><aiohttp><pytest-aiohttp> | 2023-05-24 08:26:47 | 1 | 580 | Mr.Slow |
76,321,460 | 2,966,197 | Llamaindex cannot persist index to Chroma DB and load later | <p>I am creating 2 apps using <code>Llamaindex</code>. One allows me to create and store indexes in <code>Chroma DB</code> and other allows me to later load from this storage and query.</p>
<p>Here is my code to load and persist data to ChromaDB:</p>
<pre><code>import chromadb
from chromadb.config import Settings
chrom... | <python><llama-index><chromadb> | 2023-05-24 08:21:49 | 1 | 3,003 | user2966197 |
76,321,441 | 18,987,572 | How to open a Python 3.x instance in LabVIEW2016? | <p>For research purposes I have written a script in Python 3, and now this method should be included into the production cycle, which is running LabVIEW2016.</p>
<p>The script takes a matrix corresponding to a grayscale image and a float as command line arguments and prints a float after doing some image processing. Ti... | <python><labview> | 2023-05-24 08:19:46 | 0 | 445 | king_of_limes |
76,321,276 | 49,189 | How can I update LinkedIn Basic profile in Python | <p>I am trying to update LinkedIn profile using this Python code :-</p>
<pre><code>import requests
access_token = "xxx"
profile_id = "me" # "me" refers to the currently authenticated user's profile
new_headline = "New Headline Text"
new_summary = "New Summary Text"
d... | <python><rest><linkedin-api><rest.li> | 2023-05-24 07:57:23 | 2 | 2,565 | Chakra |
76,321,217 | 1,574,551 | Create a list of start date and end date in python with first day of month and last day of month | <p>I need a list of start date end date starting with the first day of month and last day of month. Output should look like below:</p>
<pre><code> start_date = datetime.date(2023, 1, 1)
Output:
2023-01-01 2023-01-31
2023-02-01 2023-02-28
2023-03-01 2023-03-31
2023-04-01 2020-04-30
2020-05-01... | <python><list> | 2023-05-24 07:48:51 | 4 | 1,332 | melik |
76,321,120 | 11,720,193 | Error encountered with POST request to Botify | <p>I am trying to send a <code>POST</code> response to <code>Botify</code> and receive response as mentioned in the documentation <a href="https://developers.botify.com/docs/export-job-reference" rel="nofollow noreferrer">here</a>. However, the job keeps on failing. I haven't used Botify before so requesting help in fi... | <python><python-requests> | 2023-05-24 07:36:55 | 0 | 895 | marie20 |
76,321,113 | 619,774 | Access denied when trying to access USB HID device via pyusb | <p>I want to send data to a USB HID device with Python. Here's my script:</p>
<pre><code>import usb.core
import usb.util
# Device constants
VENDOR_ID = 0x1b1c
PRODUCT_ID = 0x0a6b
# Find our device
dev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
# Set the active configuration.
# With no arguments, the f... | <python><linux><usb><manjaro> | 2023-05-24 07:36:08 | 1 | 9,041 | Boris |
76,321,038 | 2,717,424 | Pandas: Referring to previous calculation results within the same calculation step | <p>I have a Pandas DataFrame and want to calculate a new column based on values of the current row and the previous one.
The following, where I just add the current value and the previous value, example works fine:</p>
<pre class="lang-py prettyprint-override"><code>df = pd.DataFrame(data=[1,2,3,4,5], columns=["ol... | <python><pandas> | 2023-05-24 07:25:16 | 1 | 1,029 | Sebastian Dine |
76,320,904 | 426,132 | Python can't parse command line arguments | <p>I'm trying to get the arguments by using getopt</p>
<pre><code>import sys
import getopt
import time
from datetime import timedelta
start_time = time.monotonic()
filename = ''
startIndex = 1
debug = False
outputFile = 'output.csv'
try:
opts, args = getopt.getopt(sys.argv[1:], "hc:o:", ["help&quo... | <python><getopt> | 2023-05-24 07:05:55 | 1 | 1,441 | user426132 |
76,320,737 | 10,669,819 | How to copy Flask Python Artifacts files to Windows Server using DEVOPS Pipelines | <p>I have a pipeline for Python Flask Project which have two stages. 1st is build and Test and other is deployment.</p>
<p>In Deployment Stage I want to copy artifacts files to my Remote Windows Server which can be only accessed by IP with Port. How can I do it?</p>
<p>I have tried few things</p>
<ol>
<li><p>Window Mac... | <python><powershell><azure-pipelines><azure-pipelines-yaml> | 2023-05-24 06:42:55 | 3 | 580 | Usman Rafiq |
76,320,554 | 11,357,695 | Import errors after updating spyder and python | <p>--
EDIT - <code>conda list</code> output (top few lines)</p>
<pre><code># packages in environment at C:\ANACONDA3:
#
# Name Version Build Channel
_ipyw_jlab_nb_ext_conf 0.1.0 py39haa95532_0
alabaster 0.7.12 pyhd3eb1b0_0
altair ... | <python><anaconda><conda><spyder><importerror> | 2023-05-24 06:15:50 | 1 | 756 | Tim Kirkwood |
76,320,436 | 9,652,160 | How can I handle different tensor sizes in the forward() method in PyTorch? | <p>I'm training an <a href="https://en.wikipedia.org/wiki/Long_short-term_memory" rel="nofollow noreferrer">LSTM</a> model, and I use a window size of 20. However, I need the output tensor to have a shorter length.</p>
<p>This small code fragment illustrates what I'm trying to do.</p>
<pre><code>def forward(self, x):
... | <python><pytorch><artificial-intelligence> | 2023-05-24 05:53:19 | 0 | 505 | chm |
76,320,424 | 13,994,829 | Python: memory leak with memory_profiler | <p>I want to use <code>memory_profiler</code> package to analyze memory usage.</p>
<p>However, I've some confusions:</p>
<h2>Example 1</h2>
<pre class="lang-py prettyprint-override"><code># test1.py
from memory_profiler import profile
class Object:
def __init__(self):
pass
list = []
@profile
def func():... | <python><memory-leaks><memory-profiling> | 2023-05-24 05:50:19 | 0 | 545 | Xiang |
76,320,365 | 8,801,862 | Pass file (model weight) as an argument to Docker Image | <p>I have a problem with loading a file to a Docker image. I would like to pass the file path as an argument and then be able to access (read) it from inside the image.</p>
<h3>File <em>model.py</em></h3>
<pre><code>if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--image-path', ty... | <python><docker><machine-learning><dockerfile> | 2023-05-24 05:38:42 | 3 | 401 | user13 |
76,320,274 | 7,185,934 | Post install script for pyproject.toml projects | <p>I am building a Python package using setuptools in a pyproject.toml file. The package is being installed locally using <code>pip install .</code></p>
<p>Is there a way to specify running a post-install Python script in the pyproject.toml file?</p>
| <python><setuptools><pyproject.toml> | 2023-05-24 05:19:38 | 0 | 815 | David Skarbrevik |
76,320,197 | 2,966,197 | streamlit app not loading background image | <p>I am building a steamlit page with multipage support and want to put a background image and another banner image in it. When I run the app, I see the banner image but the background image is not showing. Here is my code:</p>
<pre><code>import os
import streamlit as st
import numpy as np
from PIL import Image
# Cus... | <python><streamlit> | 2023-05-24 04:59:32 | 1 | 3,003 | user2966197 |
76,319,631 | 610,569 | How can I use/load the downloaded Hugging Face models from snapshot_download? | <p>I have downloaded the model from <a href="https://en.wikipedia.org/wiki/Hugging_Face" rel="nofollow noreferrer">Hugging Face</a> using <code>snapshot_download</code>, e.g.,</p>
<pre><code>from huggingface_hub import snapshot_download
snapshot_download(repo_id="facebook/nllb-200-distilled-600M", cache_dir=... | <python><machine-learning><huggingface-transformers><large-language-model><huggingface-hub> | 2023-05-24 01:58:54 | 1 | 123,325 | alvas |
76,319,288 | 6,467,512 | Can you use a custom trained model for feature extraction? | <p>I am trying to develop an algorithm using features extracted from images to find similar items.</p>
<p>I have this code I am working with:</p>
<pre><code>def get_pil_image_from_path(path):
try:
image = Image.open(path)
except Exception as e:
print(e)
return image
def get_color_image(img)... | <python><tensorflow><machine-learning><keras><resnet> | 2023-05-23 23:52:07 | 1 | 323 | AynonT |
76,319,286 | 4,117,496 | Django template loop through dict and render it value below key | <p>I'm using Django template to generate an HTML page in which I'm going through a dict, the key is an URL to a picture, the value is the caption to that image, what I'd like to render is in each row, the caption being right below the image, and render all entries (always four) in a dict in the same row, here's my code... | <python><django><templates><django-views><django-templates> | 2023-05-23 23:51:17 | 2 | 3,648 | Fisher Coder |
76,319,082 | 1,558,035 | Why can't I find the redis module for langchain vectorstores? | <p>I am trying to just simply store some embeddings that I have already generated using a Redis container. I get the error on import..</p>
<pre><code>from langchain.vectorstores.redis import Redis
</code></pre>
<hr />
<pre><code>ModuleNotFoundError: No module named 'langchain.vectorstores.redis'
</code></pre>
<p>This i... | <python><redis><langchain> | 2023-05-23 22:46:37 | 1 | 1,276 | Ostap Hnatyuk |
76,319,055 | 758,811 | Can Symppy combine an expression with `Max` and another operator like `|` | <p>I'm trying to simplify a complex equation but don't seem to combine <code>Max</code> with bitwise operators. Here is a minimal example.</p>
<pre class="lang-py prettyprint-override"><code>from sympy import simplify, symbols
a,b,c = symbols("a,b,c")
simplify("Max(a, b) | c")
</code></pre>
<p>Gives... | <python><sympy> | 2023-05-23 22:40:25 | 0 | 629 | BrT |
76,319,019 | 12,297,767 | Cannot Create Path Hierarchy Tokenizer in Azure Cognitive Search | <p>I am creating an index for Azure Cognitive Search using the Python SDK. I am trying to create a custom analyzer using a custom tokenizer. My definitions are as follows</p>
<pre><code>tokenizer = [
{
"name": "taxonomy_delimiter",
"@odata.type": "#Microsoft.Azure.... | <python><sdk><tokenize><azure-cognitive-search> | 2023-05-23 22:30:24 | 1 | 564 | Fruity Medley |
76,318,819 | 344,669 | Python generate the ClientRequestException object for unit testing | <p>For my <code>Python</code> application unit test, I need to generated the <code>ClientRequestException</code> object, to test the failure condition. using the below code to generate the exception object, but getting the error message.</p>
<p><strong>Code:</strong></p>
<pre><code> from office365.runtime.client_re... | <python><python-3.x><pytest> | 2023-05-23 21:40:38 | 1 | 19,251 | sfgroups |
76,318,661 | 3,826,115 | Holoviews interactive plot of gridded data with slider on top | <p>This code creates an interactive plot with Holoviews:</p>
<pre><code>import numpy as np
import xarray as xr
import holoviews as hv
hv.extension('bokeh')
# Create sample data
x = np.linspace(-10, 10, 10)
y = np.linspace(-10, 10, 10)
time = np.arange(0, 10, 1)
data = np.random.rand(len(time), len(x), len(y))
# Creat... | <python><bokeh><holoviews> | 2023-05-23 21:09:36 | 1 | 1,533 | hm8 |
76,318,650 | 3,175,046 | Adding a primitive type repeated field in a protobuf from python | <p>I have a proto2 file defined like the following:</p>
<pre><code>message X {
repeated A a = 1;
repeated B b = 2;
}
message BtoOtherBEntry {
required uint64 parent_b = 1; // key
repeated uint64 children_b = 2; // value
}
</code></pre>
<p>Then I have a python code that maps a type uint64 B to a list of B.
Let'... | <python><list><dictionary><protocol-buffers> | 2023-05-23 21:08:00 | 1 | 1,015 | Hadi |
76,318,624 | 448,192 | Type hint a field that can be None with a default value | <p>When using Python 3.10 in PyCharm and type hinting my methods I am noticing something that confuses me a bit and I am looking for the correct approach and also understanding what causes the following.</p>
<p>If I have this method:</p>
<pre><code>def my_method(value: str = None) -> None:
...
</code></pre>
<p>a... | <python><pycharm><python-typing> | 2023-05-23 21:02:30 | 1 | 16,160 | DArkO |
76,318,571 | 16,484,106 | How do I prevent losing a row when extracting a table from a PDF than spans multiple pages? | <p>I have a PDF table with a total of 33 rows, however this number can change. The table expands onto a second page which means it looks like two separate tables.</p>
<p>My goal is to take all items in column 0, 2, and 3 and add to three separate lists. I have been able to get this working but I noticed one row is miss... | <python><python-3.x><pdf><tabular> | 2023-05-23 20:52:05 | 1 | 384 | agw2021 |
76,318,541 | 2,930,456 | C program crashes on windows when run from Python program | <p>I'm trying to run a C program from a Python program using <code>subprocess.run()</code> on Windows 11. However when the C program is run using <code>subprocess.run()</code> the C program does not run and returns <code>3221225781</code>. But when I run the C program directly and not from python it runs fine and print... | <python><c><python-3.x><windows><mingw> | 2023-05-23 20:47:04 | 0 | 1,401 | 2trill2spill |
76,318,261 | 1,264,933 | LangChain - create_sql_agent prompt, though, and observation output | <p>When creating a <code>create_sql_agent()</code> how do you get the prompt, thought, and observation?</p>
<p>I know how to get the final answer which is just the response of the <code>agent_executor.run</code> but I would like to get the various observations and graph the results.</p>
<p>Code example shows just the &... | <python><langchain><large-language-model> | 2023-05-23 20:00:23 | 1 | 875 | peterlandis |
76,318,098 | 20,726,966 | Could not build wheels for pycrypto, which is required to install pyproject.toml-based projects - ERROR | <p>I'm facing an error while deploying to Heroku. ERROR: Could not build wheels for pycrypto, which is required to install pyproject.toml-based projects. However, my project does not specify use for pycrypto. What is causing this issue? My requirements.txt looks like:</p>
<ul>
<li>python==3.10.9</li>
<li>firebase_admin... | <python><heroku><plotly-dash> | 2023-05-23 19:36:32 | 3 | 318 | Homit Dalia |
76,318,047 | 1,452,762 | Complete sequence between a range in python | <p>I have a range that is decided (e.g., 0 to 14). I have a list of list with at least one sequence as a sublist already in the list of list in ascending order (e.g., [[6, 7], [10, 11, 12]]). I need a function that completes the sequence from 0 to 14 with the already included sequences intact. For the running example, ... | <python><sequence> | 2023-05-23 19:28:32 | 2 | 315 | Les_Salantes |
76,317,946 | 2,717,424 | Calculate Exponential Moving Average using Pandas DataFrame | <p>I want to calculate the exponential moving average (<strong>EMA</strong>) for a set of price data using Pandas.
I use the formula from <a href="https://plainenglish.io/blog/how-to-calculate-the-ema-of-a-stock-with-python" rel="nofollow noreferrer">this article</a> as well as the test data from its example calculatio... | <python><pandas><moving-average><technical-indicator> | 2023-05-23 19:11:57 | 1 | 1,029 | Sebastian Dine |
76,317,880 | 12,300,981 | Why are my errors so high for my minimized solution? | <p>I have a couple of large datasets that I am attempting to generate a theoretical model of. I am able to find a global minima/solution for this fitting, but when I attempt to calculate errors, they come out to be large even though the landscape is well defined.</p>
<p>I have the adjustable parameter of the solution I... | <python><numpy><scipy><statsmodels><scipy-optimize> | 2023-05-23 19:01:07 | 0 | 623 | samman |
76,317,508 | 9,820,561 | Method Resolution Order (MRO) in Python: super multiple inheritance | <p>I got the following example code. I understand that the code is falling since <code>super(A, self).__init__(attr_base1, attr_base2)</code> is calling the <code>__init__</code> of <code>B(Base)</code>, but I don't really understand why. Since I put <code>A</code> in <code>super(A, self)</code>, I thought that it shou... | <python><method-resolution-order> | 2023-05-23 18:01:44 | 1 | 362 | Mr.O |
76,317,227 | 19,130,803 | MyPy: module not found mypy-extension | <p>I am working on python app using docker. I am using <code>mypy</code> as type checker, during checking I got an error for <code>Callable[NamedArgs]</code>.</p>
<p>version <code>mypy = "^1.2.0"</code></p>
<p>Upon this, I used <code>from mypy_extensions import NamedArg</code> and corrected the error.</p>
<pr... | <python><docker><mypy> | 2023-05-23 17:18:12 | 0 | 962 | winter |
76,317,200 | 20,292,449 | Cannot open include file: 'sys/mman.h': No such file or directory | <p>I was trying to install the raspberry's GPIO pin controller library using this command on windows on vscode editors powershell terminal. How I am trying to control the raspberry pi3 pins is I am simulating the hardware design in a proteus8.13 simulation software not on an actual raspberry pi3 hardware?</p>
<pre><cod... | <python><pip><raspberry-pi3> | 2023-05-23 17:13:21 | 1 | 532 | ayex |
76,317,082 | 12,091,935 | How to get pythonpath to work for the python module in openmodelica Buildings running ubuntu 20 | <p>I am having problems running my model in openmodelica on ubuntu 20. I tried exporting the path following the documentation and installed libpython3.8-dev.
<a href="https://build.openmodelica.org/Documentation/Buildings.Utilities.IO.Python_3_8.UsersGuide.html" rel="nofollow noreferrer">https://build.openmodelica.org/... | <python><modelica><pythonpath><openmodelica> | 2023-05-23 16:55:07 | 1 | 435 | Luis Enriquez-Contreras |
76,317,031 | 4,858,605 | How to handle multiple pytorch models with pytriton + sagemaker | <p>I am trying to adapt pytriton to host multiple models for a multi-model sagemaker setup.
In my case, I am trying to get it to load all models that are hosted in the SAGEMAKER_MULTI_MODEL_DIR folder.</p>
<p>I could not find any relevnt example <a href="https://github.com/triton-inference-server/pytriton/tree/main/exa... | <python><amazon-web-services><amazon-sagemaker><triton> | 2023-05-23 16:48:20 | 1 | 2,462 | toing_toing |
76,316,915 | 1,445,660 | pike.exception.StreamLostError python pika rabbitmq | <p>I get <code>pike.exception.StreamLostError: Stream connection lost: connectionResetError(10054...</code> when I call <code>connection.channel()</code>:</p>
<pre><code>p = pika.ConnectionParameters('localhost')
c = pika.BlockingConnection(p)
channel = connection.channel()
...
</code></pre>
<p>RabbitMQ 3.11.16
Erlang ... | <python><rabbitmq><pika> | 2023-05-23 16:32:49 | 1 | 1,396 | Rony Tesler |
76,316,765 | 3,247,006 | How to pass metadata to "Metadata" section in "Payments" on Stripe Dashboard after a payment on Stripe Checkout? | <p>With the Django code below, I'm trying to pass metadata to <strong>Metadata</strong> section in <strong>Payments</strong> on <strong>Stripe Dashboard</strong>:</p>
<pre class="lang-py prettyprint-override"><code># "views.py"
from django.shortcuts import redirect
import stripe
def test(request):
check... | <python><django><stripe-payments><metadata><checkout> | 2023-05-23 16:13:18 | 2 | 42,516 | Super Kai - Kazuya Ito |
76,316,606 | 8,214,951 | Skorch NeuralNetRegressor and GridSearchCV - Custom Parameters | <p>I have the following model defined, that I would like to apply Hyperparameter tuning to. I want to use GridSearchCV and change the number of layers etc.</p>
<pre class="lang-py prettyprint-override"><code>class Regressor(nn.Module):
def __init__(self, n_layers=3, n_features=10, activation=nn.ReLU):
super... | <python><scikit-learn><pytorch><gridsearchcv><scikit-optimize> | 2023-05-23 15:52:23 | 0 | 430 | flying_loaf_3 |
76,316,414 | 386,861 | Altair returns error with single selector | <p>Trying to create a slider on the gapminder dataset from vega in Altair.</p>
<pre><code>import pandas as pd
import altair as alt
from vega_datasets import data
df= data.gapminder()
yearslider = alt.selection_single(
name="Year",
field="year",
init={"year": 1955},
bind=... | <python><pandas><altair> | 2023-05-23 15:30:31 | 1 | 7,882 | elksie5000 |
76,316,395 | 12,169,964 | converting curl url encoded data to python format | <p>I have the following working curl request which I use to update my apps manifest in slack:</p>
<pre><code>curl -D /dev/stderr -s -d app_id=<APP_ID> --data-urlencode manifest@manifest.json -H 'authorization: Bearer <CURRENT_TOKEN>' https://slack.com/api/apps.manifest.update
</code></pre>
<p>I am attemptin... | <python><curl><python-requests><slack-api> | 2023-05-23 15:28:45 | 1 | 335 | El_Birdo |
76,316,261 | 10,335 | How to edit an already created Python Script in PowerBI? | <p>In my Power BI dashboard, I created a Python Script that accesses an API and generates a Pandas data frame.</p>
<p>It works fine, but how can I edit the Python code?</p>
<p>I thought it would be something simple, but I can't really find how to find it in the interface. If I send the .pbix file to someone, they will ... | <python><powerbi><powerquery><powerbi-desktop> | 2023-05-23 15:13:03 | 2 | 40,291 | neves |
76,316,138 | 7,909,676 | Invoking Amazon Lex using audio recorded from capacitor-voice-recorder | <p><strong>TLDR;</strong> How to convert <code>audio/webm;codecs=opus</code> to <code>audio/l16; rate=16000; channels=1</code> in python.</p>
<hr />
<h2>The issue</h2>
<p>I am using <code>capacitor-voice-recorder</code> to record audio in my Ionic application. In firefox its recording audio in <code>audio/webm;codecs=... | <python><amazon-web-services><audio><amazon-lex><amazon-polly> | 2023-05-23 14:59:21 | 1 | 20,464 | Leeroy Hannigan |
76,316,081 | 13,349,935 | WebSocket connection to 'wss://127.0.0.1:8080/' failed | <h1>Problem Context</h1>
<p>I have an express server serving my webpage with HTTPS via the following code:</p>
<pre><code>const express = require("express");
const app = express();
const fs = require("fs");
const https = require("https");
const sslKey = fs.readFileSync(__dirname + "/... | <javascript><python><node.js><express><websocket> | 2023-05-23 14:54:31 | 0 | 1,392 | Syed M. Sannan |
76,316,066 | 2,610,522 | Xarray distance based sliding window in lat and lon system? | <p>I need to select all pixels within 50km of a central pixel in a lat and long coordinate system. I could do the loop but that is not ideal. Currently the <code>rolling</code> function in <code>xarray</code> is based on fixed window size. This doesn't work for me since the number of cells within 50 km depends on the l... | <python><python-xarray> | 2023-05-23 14:53:30 | 0 | 810 | Ress |
76,315,985 | 8,012,864 | Python remove duplicates form multidimensional list | <p>I have a list in python that looks like this...</p>
<pre><code>[
{
"title": "Green Jacket",
"price": "18",
"instock": "yes",
},
{
"title": "Red Hat",
"price": "5",
... | <python> | 2023-05-23 14:41:51 | 1 | 443 | jsmitter3 |
76,315,907 | 3,007,075 | Applying a function to itself multiple times in python | <p>According to the documentation of <a href="https://docs.python.org/3/library/functools.html#functools.reduce" rel="nofollow noreferrer">functools</a>, the <code>reduce</code> method is useful for</p>
<blockquote>
<p>Apply function of two arguments cumulatively to the items of iterable, from left to right, so as to r... | <python> | 2023-05-23 14:33:21 | 2 | 1,166 | Mefitico |
76,315,710 | 577,647 | Method takes 2 positional arguments but 3 were given | <p>My method actually gets 2 arguments other than self:</p>
<pre><code>class MyService(object):
def my_method(self, instance, **kwargs):
</code></pre>
<p>In the test code:</p>
<pre><code>my_service.my_method(old_instance, new_data)
</code></pre>
<p>and Python says that:</p>
<pre><code>takes 2 positional arguments b... | <python><python-3.x><django> | 2023-05-23 14:11:18 | 2 | 2,888 | tolga |
76,315,624 | 2,479,038 | Registering discriminated union automatically | <p>Using pydantic 1.10.7 and python 3.11.2</p>
<p>I have a recursive Pydantic model and I would like to deserialize each types properly using <a href="https://docs.pydantic.dev/latest/usage/types/#discriminated-unions-aka-tagged-unions" rel="nofollow noreferrer">discriminated union</a>.</p>
<pre class="lang-py prettypr... | <python><python-3.x><pydantic> | 2023-05-23 14:02:16 | 1 | 1,211 | abstrus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.