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 ⌀ |
|---|---|---|---|---|---|---|---|---|
77,075,621 | 11,561,158 | Django Query: Annotating queryset list with Sum of fields Values | <p>I have 3 simple models:</p>
<pre><code>from django_better_admin_arrayfield.models.fields import ArrayField
class Skill(BaseModel):
value = models.IntegerField()
item = models.ForeignKey(Item, on_delete=models.CASCADE related_name="skills")
class Item(BaseModel):
name = models.CharField(max_le... | <python><django> | 2023-09-10 09:59:50 | 0 | 863 | Hippolyte BRINGER |
77,075,446 | 4,246,716 | subset pandas dataframe to get specific number of rows based on values in another dataframe | <p>I have a pandas dataframe as follows:</p>
<pre><code>df1
site_id date hour reach maid
0 16002 2023-09-02 21 NaN 33f9fad6-20c5-426c-962f-bc2fbb82aecb
1 16002 2023-09-04 17 NaN 33f9fad6-20c5-426c-962f-bc2fbb82aecb
2 16002 2023-09-04 19 NaN 4a676aeb-... | <python><pandas><dataframe> | 2023-09-10 09:09:36 | 2 | 3,045 | Apricot |
77,075,348 | 11,210,476 | How to type annotate reduce function? | <p>I'm writing a very thin wrapper on top of <code>list</code> and I want to define a method called <code>reduce</code>, but I'm struggling to annotate it properly such that <code>pylance</code>, <code>mypy</code> & <code>pylint</code> cut their complaints whenever I use the method, or even define it.</p>
<p>I was ... | <python><python-typing> | 2023-09-10 08:35:40 | 1 | 636 | Alex |
77,075,322 | 4,865,874 | Why does adding bound to a TypeVar make mypy not recognize this Protocol? | <p>The assignment within <code>func()</code> below doesn't typecheck:</p>
<pre class="lang-py prettyprint-override"><code>from typing import Generic, Protocol, TypeVar
T = TypeVar("T")
V = TypeVar("V")
K = TypeVar("K", bound=int)
class Gen(Generic[T, K]):
...
class Foo(Protocol[T]):
... | <python><mypy><python-typing> | 2023-09-10 08:28:08 | 0 | 385 | leontrolski |
77,075,310 | 1,942,868 | How can I get the data used as key for group by | <pre><code>id num tuser
1 2 user1
2 2 user2
3 3 user2
4 1 user4
5 1 user4
</code></pre>
<p>For example I have table like this .</p>
<p>Now I want to get the unique data appeared in <code>tuser</code> so, the result should be
<code>user1,user2,user4</code></p>
<p>I guess it should be related with <code>gr... | <python><sql><django> | 2023-09-10 08:24:28 | 2 | 12,599 | whitebear |
77,075,244 | 1,692,384 | pip install doesn't work ('pip' is not recognized as an internal or external command) but py -m pip install -U works | <p>Using python on windows.
When I try to install new libraries using</p>
<pre><code>pip install 'library name'
</code></pre>
<p>it throws an error saying 'pip' is not recognized as an internal or external command,
operable program or batch file.</p>
<p>But instead when I use the code</p>
<pre><code>py -m pip install -... | <python><pip> | 2023-09-10 08:02:13 | 1 | 399 | Black Dagger |
77,075,194 | 893,254 | How to plot on the same object returned by a pandas histogram plot | <p>I have created a Pandas DataFrame and plotted it using <code>.hist()</code>.</p>
<p>I want to be able to draw lines/curves on top of the same figure.</p>
<p>How can I do that?</p>
<p>I was able to plot my data as a histogram using <code>df.hist(column='Example', bins=15)</code>. This assigns the returned object to <... | <python><pandas><matplotlib><histogram> | 2023-09-10 07:41:25 | 2 | 18,579 | user2138149 |
77,074,974 | 10,305,444 | rendering SVG from segments using networkx is not similar to actual SVG image | <p>I'm trying to render a SVG, it's content is pretty simple:</p>
<pre><code>
<svg width="3000" height="3000" xmlns="http://www.w3.org/2000/svg">
<path d="M217 279H473Q441 364 409.5 443.0Q378 522 345 607ZM-2 4V66H63L325 747H415L677 66H750V4H474V66H553L495 ... | <python><matplotlib><svg><networkx> | 2023-09-10 06:01:50 | 0 | 4,689 | Maifee Ul Asad |
77,074,682 | 412,655 | Is it possible for `**kwargs` to have one type for a specific name, and another type for all other names? | <p>I have a function like this:</p>
<pre class="lang-py prettyprint-override"><code>def foo(*, x: bool, **kwargs: int) -> None:
...
</code></pre>
<p>If there is an argument <code>x</code>, it must be a <code>bool</code>. Any other named argument must be an <code>int</code>.</p>
<p>Other people will write functio... | <python><typing> | 2023-09-10 03:01:58 | 0 | 4,147 | wch |
77,074,476 | 3,118,330 | FastAPI Integrity Error - Null Value or relation not-null constraint | <p>Once I did all changes to convert the example SQL (Relational) Databases (<code>https://fastapi.tiangolo.com/tutorial/sql-databases/</code>)
in <code>Async model</code> I am able to create user however for item I get the error:</p>
<pre><code>raise translated_error from error
sqlalchemy.exc.IntegrityError: (sqlalch... | <python><sqlalchemy><fastapi> | 2023-09-10 00:51:59 | 1 | 472 | dannisis |
77,074,445 | 11,890,443 | Effects of POSIX_FADV_DONTNEED when calculating SHA256 sum with python (TL;DR don't use it) | <p>Update: This is now more for documentation after doing more tests.</p>
<p>TL;DR using POSIX_FADV_DONTNEED isn't worth it. Not using it gives best speed. On AMD64 it even seems not to be respected.</p>
<p>Environment Rasperry PI4 USB 3.0 5TB spinning disk with ext4 file system</p>
<p>Using 1 thread with this config g... | <python><linux><performance> | 2023-09-10 00:31:10 | 0 | 326 | Hannes |
77,074,339 | 4,001,300 | Wagtail: custom URLs for blog page categories? | <p>My blog pages have a type and a subtype.</p>
<p>I want blog page URLs to look like <code>mysite.com/pages/<blog_type>/<blog_subtype>/<blog_title></code></p>
<p>By default, they are just <code>mysite.com/pages/<blog_title></code></p>
<p>I can't think of a way to do this (I'm new to Wagtail). C... | <python><django><wagtail> | 2023-09-09 23:25:08 | 1 | 796 | Mike Johnson Jr |
77,074,094 | 1,150,683 | Dataloader/sampler/collator to create batches based on the sample contents (sequence length) | <p>I am converting someone else's code into a neater torch-y pipeline, using datasets and dataloaders, collate functions and samplers. While I have done such work before, I am not sure how to tackle the following problem.</p>
<p>The dataset contains sentences as samples. Every samples therefore has a number of words (o... | <python><pytorch><nlp><batch-processing><dataloader> | 2023-09-09 21:28:17 | 1 | 28,776 | Bram Vanroy |
77,074,085 | 5,424,359 | AWS Amplify deploy fails becaus of typing-extensions versions | <p>My deploy to AWS amplify suddenly started failing with this error:</p>
<pre><code>ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
aws-sam-cli 1.55.0 requires typing-extensions==3.10.0.0, but... | <python><amazon-web-services><pip><aws-amplify> | 2023-09-09 21:23:26 | 0 | 710 | Flobbinhood |
77,073,979 | 6,110,557 | How to build a python package with setup.py? | <p>I'm trying to build package so that i can install it simply with pip3 command. It is an open-source project. Can someone please suggest me how to make it work.</p>
<p>This is content of my setup.py</p>
<pre><code>from setuptools import setup, find_packages
setup(
name='hawkeye',
version='0.1.0',
des... | <python><python-3.x><installation><pip><setup.py> | 2023-09-09 20:37:43 | 1 | 400 | rohitcoder |
77,073,915 | 2,620,838 | How to run alembic migrations inside of an AWS Lambda? | <p>I created a CircleCI pipeline that builds an AWS infrastructure using Terraform.</p>
<p>The problem now is how to run the Alembic migrations.</p>
<p>So, how to run alembic migrations inside of an AWS Lambda?</p>
| <python><amazon-web-services><aws-lambda><alembic> | 2023-09-09 20:18:09 | 1 | 1,003 | Claudio Shigueo Watanabe |
77,073,786 | 887,074 | Python Yaml parse inf as float | <p>In PyYaml or ruamel.yaml I'm wondering if there is a way to handle parsing of specific strings. Specifically, I'd like to be able to parse <code>"[inf, nan]"</code> as <code>[float('inf'), float('nan')]</code>. I'll also note that I would like <code>"['inf', 'nan']"</code> to continue to parse as... | <python><pyyaml><ruamel.yaml> | 2023-09-09 19:38:23 | 1 | 5,318 | Erotemic |
77,073,147 | 1,852,526 | Parse XML with namespace attribute changing in Python | <p>I am making a request to a URL and in the xml response I get, the xmlns attribute namespace changes from time to time. Hence finding an element returns None when I hardcode the namespace.</p>
<p>For instance I get the following XML:</p>
<pre><code><package xmlns="http://schemas.microsoft.com/packaging/2012/0... | <python><xml><elementtree> | 2023-09-09 16:43:10 | 4 | 1,774 | nikhil |
77,072,972 | 7,077,532 | Python: Pandas Dataframe -- Convert String Time Column in mm:ss Format to Total Minutes in Float Format | <p>Let's say I have a python dataframe with a time related column called "Time". Inside this column there are strings that represent minutes and seconds. For example, the first row value 125:19 represents 125 minutes and 19 seconds. Its datatype is a string.</p>
<p>I want to convert this value to total min... | <python><dataframe><time><string-conversion><minute> | 2023-09-09 15:53:31 | 2 | 5,244 | PineNuts0 |
77,072,770 | 10,418,143 | Simple Linear Regression Model parameters not getting updated | <p>I have been following one of the tutorial of PyTorch of creating a Simple Linear Regression model.</p>
<p>I have followed up accordingly here's the code for reference.</p>
<pre><code>class LinearRegression(nn.Module):
def __init__(self):
super().__init__()
self.bias = nn.Parameter(torch.randn(1, requires... | <python><machine-learning><pytorch> | 2023-09-09 14:55:35 | 1 | 352 | user10418143 |
77,072,672 | 13,793,478 | python data formatting in Django | <p>I get this flow of data from database. but I couldn't figure out how to format it. this is how I want it;</p>
<pre><code>This is how it is.
[{'date': datetime.date(2023, 5, 27), 'pnl': '69'}, {'date': datetime.date(2023, 7, 23), 'pnl': '81'}, {'date': datetime.date(2023, 9, 12), 'pnl': '67'} ]
</code></pre>
<pre><co... | <python><django><django-models><django-views> | 2023-09-09 14:27:39 | 1 | 514 | Mt Khalifa |
77,072,610 | 19,238,204 | How to Implement Brachistochrone with Manim SciPy/SymPy/Numpy and Python | <p>I am just learning about <code>manim</code> from the tutorial, I modify to add another line, just a <code>-x+50</code>, then I was wondering whether the ball that are moving is actually correct, can we determine the speed for each curve?</p>
<p>this is my code :</p>
<pre><code># python3 -m manim manim-argminexample.... | <python><numpy><sympy><manim> | 2023-09-09 14:12:37 | 0 | 435 | Freya the Goddess |
77,072,374 | 3,387,716 | Classify input numbers into fixed ranges, several million of times | <p>I have a few ranges (that can overlap) as parameter; for example:</p>
<pre class="lang-py prettyprint-override"><code># tuple[0] <= n < tuple[1]
ranges = [(70, 80), (80, 120), (120, 130), (120, 2000), (1990, 2000), (2000, 2040), (2040, 2050)]
</code></pre>
<p>And I have a list of tuples as input, where the se... | <python> | 2023-09-09 13:01:33 | 1 | 17,608 | Fravadona |
77,072,040 | 10,305,444 | font.getGlyphID gives KeyError on unicode | <p>I'm trying to render SVG out of an unicode using Python's fonttools:</p>
<pre><code>from fontTools.ttLib import TTFont
from fontTools.pens.svgPathPen import SVGPathPen
def unicode_to_svg(unicode_char, font_path, output_svg_path):
# Load the TTF font using fonttools
font = TTFont(font_path)
# Get the gl... | <python><svg><unicode><graphics><truetype> | 2023-09-09 11:42:31 | 2 | 4,689 | Maifee Ul Asad |
77,072,034 | 19,318,120 | Django query by parent id without join | <p>Let's say I've two models
Parent and Child related by foreign key</p>
<p>want to query all children without making a join with the parent table</p>
<p>will</p>
<pre><code>Child.objects.filter(
parent_id=parent_id
)
</code></pre>
<p>do the trick?
notice I'm doing a single underscore instead of double, so in theor... | <python><django> | 2023-09-09 11:40:32 | 1 | 484 | mohamed naser |
77,071,698 | 2,602,550 | A postgresql db does not exist after its successful creation | <p>The following code fails, and I have run out of ideas. How come I get an exception stating that the DB does not exist, when it gets successfully created?</p>
<pre class="lang-py prettyprint-override"><code> db_url = f"postgresql://{priv_user}:{priv_password}@{db_host}:{db_port}/grocerylists"
... | <python><postgresql><sqlalchemy> | 2023-09-09 09:51:08 | 1 | 355 | chronos |
77,071,658 | 5,303,845 | Error in getting specific node shape, edge color and edge weight | <p>I want to plot a directed graph for a group of genes. Let's say some genes are oncogenes, and some are driver genes. Further, the gene-gene interactions are weighted and represented using specific shapes and colours. I am using the following code to draw the directed graph:</p>
<pre><code>
import networkx as nx
... | <python><graph><networkx><directed-graph> | 2023-09-09 09:37:26 | 1 | 622 | Lot_to_learn |
77,071,549 | 2,469,032 | What is the difference between relativedelta() and DateOffset() | <p>I am having trouble understanding the differences between the relativedelta() function from the dateutil module and the DateOffset() function from Pandas. To me their syntax and outcomes are the same. For example:</p>
<pre><code>import pandas as pd
from dateutil.relativedelta import relativedelta
current_date = pd.... | <python><pandas><datetime><timedelta><python-dateutil> | 2023-09-09 09:09:50 | 2 | 1,037 | PingPong |
77,071,544 | 1,668,622 | Is it possible to let a function's generic return type be based on the last of variadic positional arguments? | <p>I want to implement a function which can be called with one or more callables as arguments and let the return type be the same as the the return type of the last provided callable.</p>
<p>So (without the type hinting) I want to be able to call e.g. <code>foo()</code> the following ways:</p>
<pre class="lang-py prett... | <python><mypy><python-typing> | 2023-09-09 09:08:32 | 1 | 9,958 | frans |
77,071,473 | 11,501,976 | Where can I import "DataclassInstance" for mypy check? | <p>I have been using custom-defined <a href="https://stackoverflow.com/a/55240861/11501976">DataclassProtocol</a> to annotate the arg of function which takes dataclass type. It was something like this:</p>
<pre class="lang-py prettyprint-override"><code>import dataclasses
from typing import Type
class DataclassProtoc... | <python> | 2023-09-09 08:43:51 | 1 | 378 | JS S |
77,071,445 | 19,130,803 | Convert plotly express graph into json | <p>I am using <code>plotly express</code> to create different graphs. I am trying to convert <code>graphs</code> into <code>json</code> format to save in <code>json</code> file. While doing so I am getting error using different ways as below:</p>
<pre><code>Way-1 code gives error as below
Error-2 Object of type ndarray... | <python><pandas><plotly-dash><plotly-express> | 2023-09-09 08:35:24 | 1 | 962 | winter |
77,071,419 | 4,393,334 | LLM Agent Executor gives InvalidRequestError "Unrecognized request argument supplied: functions" | <p>I get an error "InvalidRequestError: Unrecognized request argument supplied: functions" for the following code I tried to copy-paste from <a href="https://python.langchain.com/docs/modules/agents/" rel="nofollow noreferrer">https://python.langchain.com/docs/modules/agents/</a></p>
<p>The error happens afte... | <python><langchain><large-language-model> | 2023-09-09 08:26:30 | 1 | 3,113 | Andrii |
77,071,384 | 893,254 | Python3 and pip3 venv: Is there a global environment? Where is it? | <h1>Is there one or more System-wide or User-Account-wide Global Python3 Virtual Environment?</h1>
<ul>
<li>Is it globally available across the whole Operating System?</li>
<li>Is it visible only to each individual User Account? (This may depend on <em>where</em> on the host OS it lives)</li>
</ul>
<p>I am trying to un... | <python><visual-studio-code><python-venv> | 2023-09-09 08:13:51 | 1 | 18,579 | user2138149 |
77,071,361 | 5,924,264 | Is there a functional difference between using parameterized query vs string interpolation? | <p>I'm working with a py2 codebase that performs the following query:</p>
<pre><code>import datetime
# conn is a connector pointing to the sql database
cursor = conn.cursor()
cursor.execute('select * from table_name where end >= :start and end <= :end',
{ 'start' : datetime.datetime.combine(date, datetime... | <python><sql><datetime> | 2023-09-09 08:06:23 | 1 | 2,502 | roulette01 |
77,071,244 | 16,420,204 | Polars: Calculate rolling mode over multiple columns | <p>I have a <code>polars.DataFrame</code> like:</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
df = pl.from_repr("""
┌──────┬──────┬──────┬──────┬──────┐
│ col1 ┆ col2 ┆ col3 ┆ col4 ┆ col5 │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 ┆ i64 ┆ f32 │
╞══════╪══════... | <python><dataframe><python-polars><rolling-computation> | 2023-09-09 07:22:32 | 1 | 1,029 | OliverHennhoefer |
77,070,883 | 16,948,533 | Performance Comparison - Mojo vs Python | <p>Mojo, a programming language, claims to be 65000x faster than python. I am eager to understand if is there any concrete benchmark data that supports this claim? Also, how does it differ in real world problems?</p>
<p>I am primarily encountered this claim on their website and have watched several videos discussing Mo... | <python><performance><benchmarking><mojolang> | 2023-09-09 04:49:48 | 1 | 1,700 | Muneeb |
77,070,782 | 355,715 | How to pipe input to urwid? | <p>I'd like to make a program in Python that works a bit like fzf - you pipe input, manipulate it, and it's piped to something else.</p>
<p>I have tried making a program like this in Python using urwid. If I set up a fake input within the program, it works the way I want it to, but if I pipe input (<code>cat foo.txt | ... | <python><pty><tui><urwid> | 2023-09-09 03:53:51 | 1 | 15,817 | polm23 |
77,070,699 | 4,225,430 | Django - confused about naming class and parameters (when to use uppercase / plural form)? | <p>Such confusion reflects unclear understanding about class and framework.</p>
<p>I'm learning database in Django models. I get confused about naming class. When to use uppercase / lowercase, when to use singular and plural? I'm following the lecture from <a href="https://www.youtube.com/watch?v=jBzwzrDvZ18&t=1974... | <python><django><class><naming-conventions> | 2023-09-09 03:11:45 | 2 | 393 | ronzenith |
77,070,586 | 11,218,687 | How to handle the sqlite3.OperationalError: database is locked | <p>I used Python code that followed the pattern:</p>
<pre class="lang-py prettyprint-override"><code>database = sqlite3.connect("path to database")
for job in range(1000):
for row in database.execute("SELECT something"):
database.execute("UPDATE something for the row")
... | <python><sqlite><database-locking><sqlite3-python> | 2023-09-09 01:55:17 | 0 | 6,630 | Dmitry Kuzminov |
77,070,438 | 2,681,662 | Create a Tempfile with lifespan as the object | <p>I have a project where I need to create temp files.</p>
<p>I have a class that accepts a file path. and as needed it reads the data from the file. However, sometimes I have the data and I want to create the same object so I use <code>tempfile</code>. But I want the file to be deleted as the object garbage-collected.... | <python><temporary-files> | 2023-09-09 00:36:32 | 1 | 2,629 | niaei |
77,070,355 | 8,396,690 | AzCosmosDBSqlRoleAssignment issue for a group | <p>We have an AzureGroup, say <code>CMR</code>, & it has <code>> 400 members</code>. I want to give a <code>cosmosDB permission</code> for each member of the group. <code>Azure AD identity (which could be a user, security group, service principal, or managed identity)</code> for <code>CMR</code> can be used for ... | <python><azure><azure-cosmosdb><azure-identity> | 2023-09-08 23:53:15 | 1 | 379 | Dibyendu Dey |
77,070,267 | 2,532,408 | How do I create an overload annotation for a function that returns a different type when the argument is 0 vs any other integer? | <p>Is it possible to create an overload annotation for a function that returns a different type when argument is <code>0</code> vs any other integer?</p>
<pre class="lang-py prettyprint-override"><code>def foo(val: int) -> MyObjectA | MyObjectB:
if val == 0:
return MyObjectA()
return MyObjectB()
</co... | <python><mypy><python-typing> | 2023-09-08 23:13:51 | 3 | 4,628 | Marcel Wilson |
77,070,177 | 10,308,255 | How to iteratively add tuple elements to a dataframe as new columns? | <p>I am using the <code>statsmodels.stats.multitest.multipletests</code> <a href="https://www.statsmodels.org/dev/generated/statsmodels.stats.multitest.multipletests.html" rel="nofollow noreferrer">function</a></p>
<p>to correct <code>p-values</code> I have stored in a dataframe:</p>
<pre><code>p_value_df = pd.DataFram... | <python><pandas><tuples><statsmodels><python-zip> | 2023-09-08 22:39:03 | 1 | 781 | user |
77,070,154 | 2,000,548 | AWS Glue: Cannot find catalog plugin class for catalog 'spark_catalog': org.apache.spark.sql.delta.catalog.DeltaCatalog | <p>I have a Glue job in Python, which write individual parquet files to Delta Lake in S3.</p>
<pre class="lang-py prettyprint-override"><code>import sys
from awsglue.context import GlueContext
from awsglue.job import Job
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
raw_parquet... | <python><apache-spark><pyspark><aws-glue><delta-lake> | 2023-09-08 22:30:20 | 1 | 50,638 | Hongbo Miao |
77,069,937 | 706,389 | sqlalchemy core: slow performance for a simple SELECT query comparing to sqlite | <p>I've been trying to optimize some of my code that reads from an <code>sqlite</code> database via <code>sqlalchemy</code>, it seemed that reading the db was taking quite a lot of time.</p>
<p>I've reduced it to the following test: read 5 million integers from an <code>sqlite</code> database.</p>
<p>Raw <code>sqlite3<... | <python><sqlite><sqlalchemy> | 2023-09-08 21:22:38 | 1 | 2,549 | karlicoss |
77,069,773 | 893,254 | How can I install IPython in Debian 12 or Ubuntu 23.04 where pip3 prevents installation due to "externally-managed-environment"? | <p><code>python3</code> is a system wide program, just as <code>pip3</code> is.</p>
<p>I want to install <a href="https://en.wikipedia.org/wiki/IPython" rel="nofollow noreferrer">IPython</a> on <a href="https://en.wikipedia.org/wiki/Debian_version_history#Debian_12_(Bookworm)" rel="nofollow noreferrer">Debian 12</a> (B... | <python><python-3.x><ipython><python-venv><debian-bookworm> | 2023-09-08 20:43:52 | 4 | 18,579 | user2138149 |
77,069,623 | 893,254 | pandas could not be resolved from source jupyter notebook | <p>I am trying to get Python3, Pandas, Jupyter, virtual envs working on one of my remote machines, via Visual Studio Code.</p>
<p>I don't fully understand how all the moving parts interact, yet.</p>
<p>When one of my test Jupyter Notebooks is open, although I can run the Python 3 code without issue, Visual Studio Code ... | <python><pandas><jupyter-notebook> | 2023-09-08 20:07:02 | 0 | 18,579 | user2138149 |
77,069,577 | 9,731,380 | Problems using zdir in contour | <p>I'm attempting to plot 2D slices from a 3D scatter plot using matplotlib, and am having problems with the <code>zdir</code> argument.
Here is my code:</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
from scipy.stats import multivariate_normal
mean = np.arra... | <python><matplotlib><contour><matplotlib-3d> | 2023-09-08 19:59:42 | 1 | 415 | HLL |
77,069,436 | 5,451,356 | Why is the total execution time so much greater than the profiled cumulated time in Python? | <p>I'm running a Python script to find flight routes using a dataset with around 20k flights containing ~4000 flights each day. When profiling the code with <code>cProfile</code>, I print that the cumulative time recorded is much less than the query execution time. The discrepancy I'm seeing is:</p>
<pre><code>Total fu... | <python><algorithm><profiling><cprofile> | 2023-09-08 19:29:41 | 0 | 964 | terrabl |
77,069,152 | 963,319 | Poetry pytest, ModuleNotFoundError: No module named 'fastapi' | <p>I'm running <code>FastAPI</code> successfully with Poetry but I cannot run unit tests:</p>
<pre><code>poetry run pytest
platform linux -- Python 3.11.5, pytest-7.4.1, pluggy-1.3.0
rootdir: /home/jenia/git/example00
collected 0 items / 1 error ... | <python><pytest><fastapi><python-poetry> | 2023-09-08 18:31:38 | 0 | 2,751 | Jenia Be Nice Please |
77,069,092 | 2,486,083 | Python argparse with two positional arguments | <p>I am trying to use python3 argparse to get a CLI like below:</p>
<pre><code>python main.py virtual_machine deploy --name "chetan"
python main.py virtual_machine power-on
python main.py image --list
</code></pre>
<p>I tried something like this, which is not working:</p>
<pre><code>parser = argparse.Argument... | <python><argparse> | 2023-09-08 18:17:16 | 3 | 1,271 | Chetan |
77,069,045 | 3,700,524 | How to call grandparent's `__str__` from child class in python? | <p>Suppose we have 3 classes <code>grandparent</code>,<code>parent</code> and <code>child</code> where <code>parent</code> inherits from <code>grandparent</code> and <code>child</code> inherits from <code>parent</code>. I want to call the <code>__str__</code> of <code>grandparent</code> in class <code>child</code>. How... | <python><inheritance> | 2023-09-08 18:06:04 | 4 | 3,421 | Mohsen_Fatemi |
77,068,908 | 22,515,567 | How to install PyTorch with CUDA support on Windows 11 (CUDA 12)? - No Matching Distribution Found | <p>I'm trying to install PyTorch with CUDA support on my Windows 11 machine, which has CUDA 12 installed and python 3.10. When I run nvcc --version, I get the following output:</p>
<pre><code>nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Aug_15_22:09:35_Pacific_Daylight_T... | <python><pip><pytorch><dependencies> | 2023-09-08 17:37:40 | 1 | 573 | Marco Parola |
77,068,901 | 14,141,072 | Discord.py v2.0: Slash Command with Cogs integrated with OpenAI API | <p>I have been making a Discord bot using discord.py v2.0 and OpenAI API to make a AI Bot for my personal server. So firstly I will share my code.</p>
<p>This the main.py file:</p>
<pre><code>import os
import asyncio
import discord
from discord.ext import commands
intents = discord.Intents.all()
ceriumAI = commands.B... | <python><python-3.x><discord><discord.py><openai-api> | 2023-09-08 17:36:21 | 1 | 831 | Bhavyadeep Yadav |
77,068,887 | 2,302,485 | What is the error rate of DuckDB approx_count_distinct for small cardinalities? | <p>I've been trying to understand how to measure the error rate for <code>approx_count_distinct</code> in DuckDB. The database doesn't provide a way to output it. As I read from the science paper the error increases if the cardinality is low or/and it depends on the number of buckets in hyperloglog implementation but t... | <python><duckdb><hyperloglog> | 2023-09-08 17:33:59 | 1 | 402 | egor10_4 |
77,068,779 | 9,191,460 | How do I output the version of my FastAPI app? | <p>I have an application in FastAPI.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>app = FastAPI( version="v0.1.0.0" )</code></pre>
</div>
</div>
</p>
<p>I want to o... | <python><version><fastapi> | 2023-09-08 17:13:25 | 2 | 3,035 | Rui Nian |
77,068,679 | 1,252,334 | Twilio Media Streams - Twilio is not connecting to my websocket server | <p>I'm currently developing an application using Twilio Media Streams to process audio data in real-time. However, I'm encountering an issue where the call disconnects immediately after making a POST request to the /voice endpoint.</p>
<p>Here are the details of my setup:</p>
<ol>
<li>I am using Flask to host my applic... | <python><websocket><twilio> | 2023-09-08 16:55:36 | 1 | 3,104 | Defozo |
77,068,567 | 6,024,187 | How to make annotation arrows that are NOT xkcd stylized | <p>I am using matplotlib version 3.7.1 and it appears that the default annotation arrows are stylized following <a href="https://www.xkcd.com" rel="nofollow noreferrer">xkcd</a>. Here is a simple plot demonstrating this:</p>
<pre><code>fig, ax = plt.subplots(1, 1, figsize=(6, 6))
p1 = 0.3
p2 = 0.7
ax.axvline(p1, colo... | <python><matplotlib> | 2023-09-08 16:35:14 | 1 | 897 | Finncent Price |
77,068,509 | 11,686,518 | Create Pandas Dataframe in Mojo | <p>I am trying to declare a Pandas DataFrame in mojo using a list of data. I have followed the examples seen for importing and using Numpy but declaring a DataFrame is only giving errors. <strong>How do I fix this so it creates a DataFrame?</strong> Here is what I have</p>
<pre><code>from python import Python
let pd =... | <python><python-3.x><mojolang> | 2023-09-08 16:26:05 | 1 | 1,633 | Jesse Sealand |
77,068,391 | 737,971 | Optimizer keeps almost the initial values | <p>I am trying to get used to torch, and after optimizing a simple example (x^2+y^2), I tried something different.</p>
<p>This should optimize a path in a <a href="https://en.wikipedia.org/wiki/Poincar%C3%A9_disk_model" rel="nofollow noreferrer">hyperbolic</a> metric. I give as input a set of points, and it should move... | <python><pytorch> | 2023-09-08 16:04:11 | 0 | 2,499 | senseiwa |
77,068,304 | 10,216,028 | Getting returned values in multiprocessing does not work | <p>I want to control the execution of a function by checking its runtime and memory consumption. I have the following code:</p>
<pre><code>import os
import time
import psutil
from multiprocessing import Process, SimpleQueue
def my_fun(a, b, c, q):
l = []
i = 2
for _ in range(a * b * c):
l.append(i... | <python><python-3.x><multithreading><multiprocessing> | 2023-09-08 15:51:16 | 1 | 455 | Coder |
77,068,253 | 12,300,981 | How to change the size of a subplot using Axes object (without gs) | <p>Been trying to figure out how to change the size of a subplot in Matplotlib when using the Axes object. Say you setup some plot</p>
<pre><code>fig=plt.figure()
ax=np.empty((2,2,),dtype=object)
ax[0][0]=fig.add_subplot(2,2,1)
ax[0][1]=fig.add_subplot(2,2,2)
ax[1][0]=fig.add_subplot(2,2,3)
ax[1][1]=fig.add_subplot(2,2... | <python><matplotlib> | 2023-09-08 15:44:05 | 1 | 623 | samman |
77,067,914 | 11,246,868 | Django admin filter for inline model rows | <p>I have a parent model (Author) & inline models (Book)</p>
<pre class="lang-py prettyprint-override"><code>
class Author(models.Model):
age = models.IntegerField()
class Book(models.Model):
name = models.CharField(max_length=250)
price = models.CharField(max_length=250)
author = models.ForeignKey... | <python><django><django-admin><m2m> | 2023-09-08 14:52:50 | 1 | 406 | RG_RG |
77,067,865 | 1,132,544 | How to split a PySpark dataframe on column values of a separate dataframe? | <p>I have a PySpark dataframe which I want to split to two dataframes based on the condition if the value of a column exists in another dataframe.</p>
<p>For exmaple my input dataframe looks like:</p>
<pre><code>| Product | Category |
| ----------- | ----------------|
| Product A | Food |
| Prod... | <python><dataframe><pyspark><azure-synapse> | 2023-09-08 14:45:59 | 1 | 2,707 | Gerrit |
77,067,838 | 3,520,621 | Keras Transformers - Dimensions must be equal | <p>I wanted to do NER with keras model using transformers. The example was working correctly but I wanted to add some context to each words in order to help the model being more accurate. What I mean by context is "coordinate X", "coordinate Y", "width of the word", "height of the wor... | <python><keras><transformer-model> | 2023-09-08 14:42:33 | 2 | 5,236 | MHogge |
77,067,833 | 5,924,264 | Separate lru for each argument value? | <p>I need to write a sql database column getter, that takes in a column name and time, and returns the entire column of values for that column corresponding to the input time. This may be a frequent function call with the same arguments, so I would like to use an lru cache. However, I'm not sure if the frequency of the... | <python><python-2.x><lru> | 2023-09-08 14:41:52 | 2 | 2,502 | roulette01 |
77,067,781 | 7,695,845 | AnnotationBbox not showing together with plot | <p>I have this code snippet which I use to render a text box next to the plot:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
import matplotlib.pyplot as plt
from matplotlib.offsetbox import AnnotationBbox, TextArea
fig, ax = plt.subplots(layout="constrained")
f = np.array([2.15, 2.2... | <python><matplotlib> | 2023-09-08 14:34:15 | 0 | 1,420 | Shai Avr |
77,067,687 | 258,516 | fiftyone states "Not Found" instead of showing GUI | <p>I hope someone can help.</p>
<p>tyring to simply show the fiftyone GUI in Windows11. I always just says "Not Found".</p>
<p>Tried
Different Anaconda environments (Python 3.10 and 3.9)
Using jupyter notbook version
Using Python 3.10 without anaconda</p>
<p>Here is an exmaple</p>
<p><a href="https://i.sstati... | <python><fiftyone> | 2023-09-08 14:21:02 | 1 | 944 | adudley |
77,067,659 | 244,130 | Numpy: Smart way to clip array values and carry leftover to next | <p>Because of an underlying datastructure there is a maximum for values in my array.</p>
<p>Is there a smart way in numpy to clip the array and carry the leftover to next elements?</p>
<p>(I'm simlifying this to a 1D array here)</p>
<pre class="lang-py prettyprint-override"><code>In [1]: import numpy as np
In [2]: arr... | <python><numpy> | 2023-09-08 14:16:19 | 1 | 487 | kristus |
77,067,527 | 3,854,191 | Odoo-13 template Error : CacheMiss: ('my_custom_model(6,).name', None) | <p>In my server Log-file on Odoo.sh (odoo-v13), i often see the following error without understanding exactly what is the reason of that: <code>odoo.exceptions.CacheMiss: ('x_eventcoursetype(6,).x_name', None)</code></p>
<p>I can see that this error is related to my custom model x_eventcoursetype, that is a sub-categor... | <python><xml><caching><odoo><odoo-13> | 2023-09-08 13:54:47 | 1 | 1,677 | S Bonnet |
77,066,978 | 534,238 | Renovate with Google Cloud, Github, Python project, and pyproject.toml | <h1>High Level</h1>
<p>I am trying to allow <a href="https://github.com/renovatebot/renovate" rel="nofollow noreferrer">Renovate</a> to manage Python dependency updates, including updates dependent upon our own internal registry, which lives in <a href="https://cloud.google.com/artifact-registry" rel="nofollow noreferr... | <python><github><google-cloud-platform><renovate> | 2023-09-08 12:42:16 | 1 | 3,558 | Mike Williamson |
77,066,939 | 9,671,120 | Python's datetime.min with time zone (Python 3.7) | <p>If I do:</p>
<pre><code>>>> datetime.max.astimezone(pytz.UTC)
datetime.datetime(9999, 12, 31, 23, 59, 59, 999999, tzinfo=<UTC>)
>>> datetime.min.astimezone(pytz.UTC)
ValueError: year 0 is out of range
</code></pre>
<p>However:</p>
<pre><code>datetime.min.replace(tzinfo=pytz.UTC)
datetime.date... | <python><datetime><timezone> | 2023-09-08 12:37:03 | 1 | 386 | C. Claudio |
77,066,885 | 8,964,393 | Ignore invalid value in pandas dataframe column | <p>I have created the following pandas dataframe:</p>
<pre><code>import pandas as pd
import numpy as np
ds = {'col1' :
['1489900119000',
'้้คค,1']
}
df = pd.DataFrame(data=ds)
</code></pre>
<p>which looks like this:</p>
<pre><code> col1
0 1489900119000
1 ้้คค,1
</code></pre>
<p>I am trying t... | <python><pandas><list><integer> | 2023-09-08 12:27:52 | 1 | 1,762 | Giampaolo Levorato |
77,066,807 | 16,611,809 | PyQt5 is waiting for input, when installing via pip | <p>I am trying to install PyQt5 into an conda env (I need pyqt installed via pip and the same error happens with a "normal" Python <code>venv</code>. First I got a real quick error message, which is solved by installing qt5 via brew (<code>brew install qt5</code>). When I now try to create the environment wit... | <python><pyqt><pyqt5> | 2023-09-08 12:15:54 | 0 | 627 | gernophil |
77,066,528 | 13,314,888 | input n as number then return '0' & '1' as number of n rows and columns in python | <p>input n as number then return '0' & '1' as number of n rows and columns in python (without using any inbuilt type of function or library)</p>
<p>If input n = 3</p>
<pre><code>The output:
100
010
001
</code></pre>
<p>If input n = 4</p>
<pre><code>The output:
1000
0100
0010
0001
</code></pre>
<p>I tried myself ... | <python><python-3.x><python-2.7> | 2023-09-08 11:33:04 | 4 | 694 | satyajit |
77,066,489 | 2,690,578 | method polygon_to_cells seems to not exist in H3 library | <p>From the Uber h3 api documentation page (<a href="https://uber.github.io/h3-py/api_reference.html#" rel="nofollow noreferrer">https://uber.github.io/h3-py/api_reference.html#</a>), they have a method called: <strong>polygon_to_cells</strong> which is suppose to transform a given Polygon to a H3 index given a H3 reso... | <python><h3> | 2023-09-08 11:27:13 | 2 | 609 | Gabriel |
77,066,445 | 6,086,115 | How to show the tooltip for the top layer only in multi-layer plotly graphs? | <p>I have a multi-layer plotly express timeline showing grey blocks with blue activities on them. Both blocks and activities have a tooltip. When hovering over them, I want to show the tooltip for the top layer only: i.e. when hovering over a blue activity (on the top layer), the tooltip for the activity must be displa... | <python><plotly><tooltip><timeline> | 2023-09-08 11:20:37 | 0 | 351 | Jordi |
77,066,094 | 3,873,799 | Extract annotations by layer from a PDF in Python | <p>I have a PDF with annotations (markups) stored in different layers. Each layer has a specific name. I need to extract the annotations with their layer name. In particular, I'm interested only in the <em>location</em> of the annotation (as in, the bounding box of it) and the name of their layer, i.e. an output like:<... | <python><pdf><annotations><extract><pypdf> | 2023-09-08 10:26:29 | 2 | 3,237 | alelom |
77,066,079 | 16,222,937 | Python: Expected expression error on end if | <p>I'm quite new to the Python programming language and am just working on a basic project to sort of try to grasp the basics. This may have been asked before but I can't really get a clear answer (most of the answers I see don't include end if). I'm not sure if it means that I've used wrong spacing somewhere or if I'm... | <python><pylance> | 2023-09-08 10:23:33 | 1 | 443 | CloakedArrow |
77,066,014 | 7,339,624 | Difference between `plt.imshow()` and `plt.matshow()` for Heatmaps | <p>I'm working with the following matrix, and I want to creat a heatmap using <code>Matplotlib</code>:</p>
<pre class="lang-py prettyprint-override"><code>a = [[1, 1, 1, 1], [1, 2, 3, 4], [4, 3, 2, 1], [4, 4, 4, 4]]
</code></pre>
<p>I've read the documentation and understand that <code>plt.imshow()</code> is a more gen... | <python><matplotlib><visualization><heatmap> | 2023-09-08 10:14:37 | 1 | 4,337 | Peyman |
77,065,700 | 292,291 | How do I update value of a ContextVar in an async function? | <p>It seems that when I reference a <code>contextlib.ContextVar</code> in an async function its a copy of the actual. Thus when I update its value it wont be persisted, is there a way to pass the context by reference instead?</p>
<pre class="lang-py prettyprint-override"><code>import asyncio
from contextvars import Con... | <python><python-asyncio> | 2023-09-08 09:27:54 | 0 | 89,109 | Jiew Meng |
77,065,631 | 15,682,259 | How to Handle Authentication Errors in Python Flask? | <p>I'm working on a Python Flask web application that requires user authentication. I've implemented a basic authentication system using Flask-Login, but I'm encountering some issues with handling authentication errors. Specifically, when a user enters incorrect credentials, I want to display a custom error message and... | <python><authentication><flask><error-handling><flask-login> | 2023-09-08 09:17:08 | 0 | 467 | Bernardo Almeida |
77,065,569 | 5,562,092 | setuptools and files not installed | <p>So the issue is quite confusing.
Conventionally I have a basic structure in a python package</p>
<pre><code>setup.py
requirements.txt
src/
package_name/
file1.py
file2.py
__init__.py
</code></pre>
<p>The above installs great but the one below doesnt.</p>
<pre><code>setup.py
requirements.txt
src/
f... | <python> | 2023-09-08 09:08:09 | 0 | 875 | A H Bensiali |
77,065,296 | 5,547,553 | How to make polars in python not quote anything in write_csv? | <p>I'm generating a javascript data file in polars and when writing it out, I'd like polars NOT to quote anything.<br>
How can I do that?
This is still quoting (and quote parameter cannot be None or empty):</p>
<pre><code>import polars as pl
data = ['// 2023.09.01.',
'var mydata = [',
'[11.407538,22.003... | <python> | 2023-09-08 08:24:41 | 0 | 1,174 | lmocsi |
77,065,281 | 14,282,714 | Reset Zoom of Interactive Altair | <p>I would like to have a way (button for example) to reset the zoom in or zoom out to some start of an interactive plot from <code>altair</code>. Here is some reproducible code:</p>
<pre><code>import altair as alt
from vega_datasets import data
cars = data.cars()
alt.Chart(cars).mark_point().encode(
x='Horsepower... | <python><zooming><altair> | 2023-09-08 08:22:57 | 1 | 42,724 | Quinten |
77,065,235 | 634,780 | How to check for a TypeVar actual type and keep mypy happy | <p>I have a type bound defined as</p>
<pre class="lang-py prettyprint-override"><code>T = TypeVar("T", bool, int, str)
</code></pre>
<p>and I want to pass <strong>type</strong> (not a value) T to a method, defined as</p>
<pre class="lang-py prettyprint-override"><code>def env(value_type: Type[T]) -> Option... | <python><mypy> | 2023-09-08 08:15:53 | 0 | 1,635 | icepopo |
77,065,234 | 2,069,099 | How to add a hierarchical checkbox | <p>I try to modify the code below, to have a "curves" checkbox that would deactivate / activate all the children (actually, the code I need will handle a lot of those, this is just an example):</p>
<p>The current code gives:</p>
<p><a href="https://i.sstatic.net/fzKtm.png" rel="nofollow noreferrer"><img src="... | <javascript><python><bokeh> | 2023-09-08 08:15:46 | 1 | 3,517 | Nic |
77,064,993 | 3,225,420 | How to only show portion of x-axis spine on scatterplot | <p>I don't want the x-axis spine between (0,0) and (0,4) to display on the scatterplot below. I still want the distance on the chart, I just don't want the spine to display between those coordinates.</p>
<pre><code>import matplotlib.pyplot as plt
x = range(4,10)
y=x
fig, ax = plt.subplots()
ax.scatter(x=x, y=y)
ax.set... | <python><matplotlib><scatter-plot><x-axis> | 2023-09-08 07:38:19 | 1 | 1,689 | Python_Learner |
77,064,942 | 10,200,497 | Understanding the cache size of arbitrary callback data in python telegram bot | <p>I have recently read the <code>python-telegram-bot</code> <a href="https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data" rel="nofollow noreferrer">docs</a> that explains the advantages of <code>arbitrary_callback_data</code>. I did not understand this sentence in the docs:</p>
<blo... | <python><python-telegram-bot> | 2023-09-08 07:29:48 | 1 | 2,679 | AmirX |
77,064,674 | 350,980 | Type hints for mypy for a decorator over staticmethod/classmethod | <p>I'm writing a helper for logger library that has decorators with specific logging for trace (debugging).</p>
<p>The code itself is correct (it is partially based on existing library), but i struggle to find how to make mypy accept types for it.</p>
<p>Question marks is where i have problems with types. Or maybe the ... | <python><python-typing><mypy> | 2023-09-08 06:39:32 | 1 | 1,422 | UnstableFractal |
77,064,582 | 13,396,497 | Remove duplicates from panda dataframe but keep the row if it repeats after another set | <p>I am trying to remove the duplicates and keep first but I also want to keep the row if the set repeats again -</p>
<pre><code>from io import StringIO
import pandas as pd
dfa = pd.read_csv(StringIO("""
Date/Time C_1 C_2
"16/08/2023 3:00:15" online offline
"16/08/2023 3:00... | <python><pandas> | 2023-09-08 06:22:11 | 4 | 347 | RKIDEV |
77,064,536 | 9,028,779 | How to update text within HTML parent tags that contain nested tags, using BeautifulSoup? | <p>I am facing challenges in using BeautifulSoup to update the text within HTML tags when those tags act as 'parent' tags containing other nested tags like <code><i></i></code> or <code><b></b></code>. The issue is that BeautifulSoup only identifies the text within the deepest nested tag and doe... | <python><html><beautifulsoup> | 2023-09-08 06:14:15 | 1 | 489 | JPM |
77,064,503 | 17,423,976 | Only 3 microphone streams are open on Raspberry Pi 4 | <p>I typed a code that listens to 8 USB microphone inputs simultaneously on the <strong>Raspberry Pi 4 B 4GB</strong>.<br />
It ran fine on the PC, but only partially ran on the Raspberry Pi.<br />
I confirmed that multiprocess and multithreading worked well, but only 3 microphones were streamed in each thread.<br />
A... | <python><python-3.x><python-sounddevice> | 2023-09-08 06:07:17 | 0 | 337 | Desty |
77,064,470 | 10,207,083 | Python Redis stream xread with "$" | <p>Does Python redis not support <code>"$"</code>? The following will not return a record when the stream is updated.</p>
<p><code>redis.xread(streams={"stream_name": "$"}, count=None, block=0)</code></p>
| <python><redis> | 2023-09-08 06:01:16 | 1 | 533 | TruBlu |
77,064,455 | 6,729,591 | PyTorch Dataloader - list indices must be integers or slices, not list | <p>I have implemented a COCO dataset as follows:</p>
<pre><code>from torch.utils.data import Dataset
from detr.datasets.coco import CocoDetection
class MyCoco(CocoDetection):
def __init__(self,
img_folder,
ann_file,
transform=None) -> None:
super().__... | <python><machine-learning><pytorch><pytorch-lightning><pytorch-dataloader> | 2023-09-08 05:58:11 | 1 | 1,404 | Dr. Prof. Patrick |
77,064,158 | 5,179,643 | How to create several Pandas dataframes and assign their names as elements from a list | <p>Let's say I have the following Pandas dataframe:</p>
<pre><code>import pandas as pd
df = pd.DataFrame({
'entity': ['foo', ' bar', 'baz', 'buzz', 'bar', 'buzz', 'foo', 'foo'],
'value': [4, 3, 2, 1, 9, 8, 7, 4]
})
df
entity value
0 foo 4
1 bar 3
2 baz 2
3 buzz ... | <python><pandas> | 2023-09-08 04:34:56 | 1 | 2,533 | equanimity |
77,064,104 | 13,078,279 | Does using render_template() with Flask-SocketIO cause non-auto-updating? | <p>I recently ported a Socket.IO app from Node.js to Python. I noticed that unlike the Node.js original, the Python version didn't autoupdate on multiple connections. While that app is far too complex to post on a simple SO question, here is a minimal reproduction of my issue.</p>
<p>Create a file called <code>template... | <python><flask><socket.io> | 2023-09-08 04:18:13 | 1 | 416 | JS4137 |
77,063,677 | 474,197 | How to pass Mojo function to Python in Python interop? | <p>The question is how to pass Mojo function to Python in Python interop?</p>
<p>For example,</p>
<pre class="lang-py prettyprint-override"><code># This is main.mojo
from python.python import Python
def callback():
return 5
def main():
Python.add_to_path(".")
let test_module = Python.import_module(&... | <python><mojolang> | 2023-09-08 01:40:45 | 1 | 3,320 | HKTonyLee |
77,063,612 | 5,924,264 | Does setattr make a deepcopy? | <p><a href="https://docs.python.org/3/library/functions.html#setattr" rel="nofollow noreferrer">https://docs.python.org/3/library/functions.html#setattr</a> From this documentation, I cannot tell if a deep copy is made or not.</p>
<p>I'm working with a codebase currently that uses <code>setattr</code> is a rather disgu... | <python><deep-copy><shallow-copy><setattr> | 2023-09-08 01:11:13 | 0 | 2,502 | roulette01 |
77,063,590 | 13,258,121 | styling Tab title text in ipywidgets | <p>Is it possible to style the title of a tab in ipywidgets?
Using the <a href="https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20List.html#tabs" rel="nofollow noreferrer">docs example</a>, is it possible to set a style for the tabs 0-4 either individually or as a collective?</p>
<pre><code>tab_contents = [... | <python><ipywidgets> | 2023-09-08 01:06:02 | 1 | 370 | Lachlan |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.