Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Code Reviews

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Posts tagged python

25 child tags

Use for questions about the Python programming language. Python is a multi-paradigm, dynamically typed, multipurpose programming language.

Consider adding a major version tag such as [python-2.7] or [python-3.x] when this is relevant for the question.

This tag doesn't have a detailed wiki yet.

50%
+0 −0
Q&A What is the reverse of an `ndarray.tolist()`?

I have a nested python list structure, generated by a happily executed tolist() method on a more than 2 dimensional ndarray. How can I get back my numpy ndarray from the list?

1 answer  ·  posted 5d ago by peterh‭  ·  last activity 5d ago by mr Tsjolder‭

Question numpy python-3
66%
+2 −0
Q&A What binds together the loss function, the optimizer and the model in PyTorch?

To have a successful "training session", these should cooperate. I.e. model generates an output from the input data, the loss function says, how bad or good is it, and then the optimizer tunes...

1 answer  ·  posted 7d ago by peterh‭  ·  last activity 5d ago by mr Tsjolder‭

Question python-3
50%
+0 −0
Q&A How to preserve pip install temporary directory for error analyse?

Here I am trying to install a pip package. While installation, pip tries to compile something. With meson. Meson calls cmake. Cmake fails on a missing dependency. Then, meson fails on the fail...

1 answer  ·  posted 8d ago by peterh‭  ·  last activity 7d ago by peterh‭

Question python-3 pip
75%
+4 −0
Q&A Why python regexps look expecting a begin match, but not an ending one?

My impression is that the regexps behave a little bit odd: >>> import re >>> r=re.compile("test") >>> r.match("test") <re.Match object; span=(0, 4), match='test'&g...

2 answers  ·  posted 10d ago by peterh‭  ·  last activity 9d ago by Karl Knechtel‭

Question regex python-3
75%
+4 −0
Q&A How to plot table from pandas dataframe

MWE import pandas as pd import numpy as np import matplotlib.pyplot as plt df = pd.DataFrame(np.random.rand(9, 4), columns=['a', 'b', 'c', 'd']) df.plot.bar(table=True) # don't want plot, ...

1 answer  ·  posted 3y ago by mcp‭  ·  edited 24d ago by Alexei‭

Question python plot pandas matplotlib
81%
+7 −0
Code Reviews A simple game with pygame

I've just started playing around with pygame and have written a small game in it, of which I'd like a review. Note that I'm not only a complete beginner in pygame, but I also have very little exper...

1 answer  ·  posted 3y ago by celtschk‭  ·  last activity 24d ago by Alexei‭

Question python game-development
60%
+1 −0
Q&A How can I display an interactive family tree-style graph in PyQt6?

I'm trying to create an expandable/collapsible horizontal visualization of interlinked documents using a tree diagram that looks very similar this, where the documents spread outward from a single ...

0 answers  ·  posted 24d ago by pycoder‭

Question python python-3 pyqt6 pyqt
66%
+2 −0
Q&A How to make Box drive have the files prepared for access when I need it?

I have Box drive on Windows. I use it as a regular folder on the computer. I can store images there. When I store a small number of images (on the order of a couple hundreds) and I do not wait lon...

1 answer  ·  posted 12mo ago by Ivan Nepomnyashchikh‭  ·  last activity 27d ago by Mithical‭

Question python windows box-drive
50%
+1 −1
Q&A How to turn lines of text in PyQt6 QTextEdit into clickable links that call a function?

A while back, I made this post about reading specified sections in a text file formatted a particular way. I've since updated the format for that file to include links at the start of arbitrary li...

1 answer  ·  posted 2mo ago by pycoder‭  ·  last activity 29d ago by Karl Knechtel‭

Question python python-3 pyqt6 pyqt
60%
+1 −0
Q&A Why would the tokenizer for encoder-decoder model for machine translation use bos_token_id == eos_token_id? How does it know when a sequence ends?

I see on this PyTorch model Helsinki-NLP/opus-mt-fr-en (HuggingFace), which is an encoder-decoder model for machine translation: "bos_token_id": 0, "eos_token_id": 0, in its config.json. ...

1 answer  ·  posted 2mo ago by Franck Dernoncourt‭  ·  last activity 1mo ago by Mithical‭

Question pytorch machine-translation tokenization encoder-decoder
50%
+2 −2
Q&A Current solution for Project Euler 250+ (HackerRank) is giving incorrect answers, why is this? [closed]

Note: I originally posted this on Stack Overflow on Stack Exchange here however I am posting the same question here as I might be able to get a answer more quickly here. Project Euler+ #250 on H...

0 answers  ·  posted 1mo ago by CrSb0001‭  ·  closed 1mo ago by Karl Knechtel‭

Question python python-3 math number-theory
50%
+0 −0
Q&A How can I save a plot in a file in PyCharm without changing the code?

How can I save a plot in a file in PyCharm without changing the code? I used plt.show(), so that the plot shows like this: But how can I save a plot in a file without changing the code? I don'...

0 answers  ·  posted 1mo ago by Franck Dernoncourt‭  ·  edited 1mo ago by Franck Dernoncourt‭

Question pycharm
40%
+0 −1
Q&A Import onnxruntime then load_dataset "causes ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found": why + how to fix?

Running import onnxruntime as ort from datasets import load_dataset yields the error: (env-312) dernoncourt@pc:~/test$ python SE--test_importpb.py Traceback (most recent call last): File...

1 answer  ·  posted 2mo ago by Franck Dernoncourt‭  ·  last activity 2mo ago by Franck Dernoncourt‭

Question python huggingface-datasets onnxruntime glibc
33%
+0 −2
Q&A Can't run a Python file in PyCharm: why? [closed]

I can't run a Python file in PyCharm: why? The run icon is greyed out: I went to Run → Edit Configurations… to make sure the correct Python interpreter is selected. Debug, coverage, and profile...

1 answer  ·  posted 2mo ago by Franck Dernoncourt‭  ·  closed 2mo ago by Karl Knechtel‭

Question python pycharm
60%
+1 −0
Q&A How can I export an encoder-decoder PyTorch model into a single ONNX file?

I converted the PyTorch model Helsinki-NLP/opus-mt-fr-en (HuggingFace), which is an encoder-decoder model for machine translation, to ONNX using this script: import os from optimum.onnxruntime im...

0 answers  ·  posted 2mo ago by Franck Dernoncourt‭  ·  edited 2mo ago by Franck Dernoncourt‭

Question python onnx pytorch machine-translation
71%
+3 −0
Q&A How to find the last line number of a section in a text file (particular format)

I'm writing a function which reads specified sections in a text file formatted a particular way, but I'm having a hard time figuring out how to locate the last line number. Here's an example of the...

1 answer  ·  posted 2mo ago by pycoder‭  ·  edited 2mo ago by hkotsubo‭

Question python python-3
66%
+2 −0
Q&A Understanding "subprocess-exited-with-error" from Pip

This question is about the general case of subprocess-exited-with-error. It's intended to help you understand the situation if you get an error like this, and there are some common workarounds - ...

1 answer  ·  posted 3mo ago by Karl Knechtel‭  ·  last activity 3mo ago by Karl Knechtel‭

Question python pip
66%
+2 −0
Q&A How can I resolve the 403 Forbidden error when deploying a fine-tuned GPT model in Azure via Python?

I follow Azure's tutorial on fine-tuning GPT. I'm stuck at the deployment phase. Code: # Deploy fine-tuned model import json import requests token = '[redacted]' subscription = '[redacted...

0 answers  ·  posted 3mo ago by Franck Dernoncourt‭

Question python azure
71%
+3 −0
Q&A Why is spacy word vectors showing unexpected similar words?

Why is spacy word vectors showing unexpected similar words? Here is the code I am using: import spacy import numpy as np nlp=spacy.load('en_core_web_md') with open ('data/us.txt') as f: ...

0 answers  ·  posted 5mo ago by Asia‭  ·  edited 5mo ago by celtschk‭

Question python-3 spacy word-vectors
75%
+4 −0
Q&A Regex to get text outside brackets

I am trying to capture the content outside square brackets in groups, using this regex: (.*)\[.*?\](.*) And it works perfectly for a simple string like this: testing_[_is_]_done This is the...

2 answers  ·  posted 1y ago by TonyMontana‭  ·  last activity 7mo ago by hkotsubo‭

Question regex python-3
66%
+2 −0
Q&A Unable to log in with Flask-WTF and Flask-Login

I'm building a Flask application with user login functionality using Flask-WTF for form handling and Flask-Login for user authentication. However, I am unable to log in successfully. The page does ...

0 answers  ·  posted 7mo ago by misbahskuy‭  ·  edited 7mo ago by Andreas demands justice for humanity‭

Question python flask
66%
+2 −0
Q&A Simultaneous comparison in Python

I want to make multiple comparisons at once, of the same type, in a Python program. For example, to check whether all of a certain group of strings are in a longer test string; or whether a specifi...

1 answer  ·  posted 7mo ago by Karl Knechtel‭  ·  last activity 7mo ago by Karl Knechtel‭

Question python operators logic
60%
+1 −0
Q&A Generating combinations of elements, which are themselves sequences of the same length, where the elements have no value in common at any position

This question is adapted from a question I just helped fix up on Stack Overflow. I'm giving a different motivating example which I think will make it clearer what the requirements are and why a n...

2 answers  ·  posted 7mo ago by Karl Knechtel‭  ·  last activity 7mo ago by Karl Knechtel‭

Question python algorithms combinatorics
60%
+1 −0
Q&A I can't install the Spacy library using the terminal in VSCode on Windows 10

I am trying to install the Spacy library in VSCode in a folder with a virtual environment. The output appearing in the terminal is excessively long; I will share it with a pastebin later. My versio...

1 answer  ·  posted 8mo ago by Richard‭  ·  last activity 8mo ago by Alexei‭

Question python visual-studio installation terminal spacy
57%
+2 −1
Q&A How to mock methods like `pathlib.Path.is_dir`?

I used to have some testing code for mocking a simple directory structure when working with pathlib. I recently tried to run these tests to learn that some of the internals in pathlib have changed ...

1 answer  ·  posted 8mo ago by mr Tsjolder‭  ·  last activity 8mo ago by mr Tsjolder‭

Question python unit-testing mocking testing
71%
+3 −0
Q&A How to format Markdown in terminal

When printing Markdown text to the terminal, how can I get a bit more formatting so it looks nicer? I realize that this is a bit of a contradiction, since terminals generally use only one font. Bu...

1 answer  ·  posted 11mo ago by matthewsnyder‭  ·  last activity 9mo ago by Michael‭

Question markdown python-3 software-recommendation pretty-print terminal
57%
+2 −1
Q&A What actually is a pytest fixture?

Pytest uses fixtures. Their docs explain what fixtures do: https://docs.pytest.org/en/stable/explanation/fixtures.html But what actually is a fixture? Is there a definition for it? Is this a term ...

1 answer  ·  posted 10mo ago by matthewsnyder‭  ·  last activity 10mo ago by Karl Knechtel‭

Question terminology testing pytest
66%
+2 −0
Q&A how can I run pytest on Flask routes?

I'm trying to implement pytest for one of my Python Flask projects. The application is instanciated like this in appname.py def create_app(): app = Flask(__name__) app.config.from_pyfil...

0 answers  ·  posted 10mo ago by GeraldS‭  ·  edited 10mo ago by GeraldS‭

Question python flask pytest
75%
+4 −0
Q&A Why does `tkinter` (or `turtle`, or IDLE) seem to be missing or broken? Isn't it part of the standard library?

I had understood that Python is supposed to come "batteries included", and that the "batteries" specifically include: the tkinter standard library, a simple GUI framework a simple IDE cal...

1 answer  ·  posted 12mo ago by Karl Knechtel‭  ·  last activity 11mo ago by Karl Knechtel‭

Question python installation tkinter
60%
+1 −0
Q&A Can you have syntax highlighting for streaming text in Python?

Suppose you have a situation where text is coming 1 word at a time, and you want to quickly show it to the user. "Quickly" is not in the sense of a performance constraint, but rather we don't want ...

2 answers  ·  posted 11mo ago by matthewsnyder‭  ·  edited 11mo ago by matthewsnyder‭

Question python-3 syntax-highlighting pretty-print data-streaming
80%
+6 −0
Q&A Use cases for raising a 'NotImplementedError' in Python

What are some legitimate use cases for raising a NotImplementedError exception in Python? How can it help express a code author's intentions to aid code maintenance and/or further development of co...

3 answers  ·  posted 11mo ago by pfabri‭  ·  last activity 11mo ago by pfabri‭

Question python exception
75%
+4 −0
Q&A Why does Pip display "error: externally-managed-environment", and what can I do about it?

My (non-Windows) operating system came with Python, but that Python didn't include Pip. I followed instructions to install Pip for the included Python, using my system's package manager. But now w...

2 answers  ·  posted 12mo ago by Karl Knechtel‭  ·  last activity 12mo ago by Alexei‭

Question python linux pip
71%
+3 −0
Q&A How can I start my Python code, from the code itself?

I have already learned how to tell the Python interpreter to run my code, but the standard approach feels a little unsatisfactory. I want the user experience to be that my program starts with the a...

1 answer  ·  posted 1y ago by Karl Knechtel‭  ·  last activity 12mo ago by Karl Knechtel‭

Question python startup
50%
+0 −0
Q&A Why can't I run freshly-installed Python from the command line on Windows?

I tried installing Python on an old computer running Windows 8[1]. I know for a fact that there was never any previous installation of Python on the machine. The installation appeared to be success...

1 answer  ·  posted 12mo ago by Karl Knechtel‭  ·  last activity 12mo ago by Karl Knechtel‭

Question python windows installation command-line-interface
71%
+3 −0
Q&A What happened, or is happening, to other parts of the standard library? Why are they going missing?

In Python 3.12, I noticed that some libraries seem to be missing or "deprecated": >>> import asynchat Traceback (most recent call last): File "<stdin>", line 1, in <module&gt...

1 answer  ·  posted 12mo ago by Karl Knechtel‭  ·  last activity 12mo ago by Karl Knechtel‭

Question python standard-library
50%
+0 −0
Q&A Why won't Matplotlib show me a plot?

I installed Matplotlib and tried a simple demo, but I got a warning message and no plot showed up: >>> import matplotlib.pyplot as plt >>> plt.plot([1,2,3],[4,5,6]) [<matplo...

1 answer  ·  posted 12mo ago by Karl Knechtel‭  ·  last activity 12mo ago by Karl Knechtel‭

Question python matplotlib
60%
+1 −0
Q&A Why does `venv` seem to be missing or broken? Isn't it part of the standard library?

I understand the benefits of virtual environments in general, and specifically I want to use a virtual environment so that I'll have access to Pip without exposing the system Python (i.e., included...

1 answer  ·  posted 12mo ago by Karl Knechtel‭  ·  last activity 12mo ago by Karl Knechtel‭

Question python installation python-venv
66%
+2 −0
Q&A Why does `pip` seem to be missing or broken? Isn't it part of the standard library?

I already know that the pip command might not correspond to the same Python that python runs. But in my case, it seems not to exist at all. I can't even run it as a Python module: $ python -m pip ...

1 answer  ·  posted 12mo ago by Karl Knechtel‭  ·  last activity 12mo ago by Karl Knechtel‭

Question python installation pip
80%
+6 −0
Q&A How and where does Python code start running? How can I control that?

Suppose I have some code in a file myscript.py like: def my_function(): print("Test") What steps do I need to take in order to make my_function run? That is to say: how do I get Python to ...

2 answers  ·  posted 1y ago by Karl Knechtel‭  ·  last activity 12mo ago by Michael‭

Question python startup entry-point
66%
+2 −0
Q&A Why can't I use a library I just installed with Pip?

I tried installing package-installation-test[1] using Pip, and it appeared to be successful. But I can't use it as advertised, either by itself or by importing it from my code: Failed attempts ...

1 answer  ·  posted 12mo ago by Karl Knechtel‭  ·  edited 12mo ago by Karl Knechtel‭

Question python installation runtime-environment pip
77%
+5 −0
Q&A Reinstall old Python libraries after update

Recently, Python updated from 3.11 to 3.12 and now all my libraries are gone. Actually they're in the old 3.11 site-packages, but now that python points to 3.12 those are not active. Every time I r...

3 answers  ·  posted 1y ago by matthewsnyder‭  ·  last activity 12mo ago by Karl Knechtel‭

Question python-3
66%
+2 −0
Q&A How can I access and use command-line arguments in Python?

In many other programming languages, the execution of code starts in a specifically named function (such as main) which is expected to have a specific signature, which allows that function to recei...

1 answer  ·  posted 12mo ago by Karl Knechtel‭  ·  last activity 12mo ago by Karl Knechtel‭

Question python startup command-line-interface
66%
+2 −0
Q&A Understanding the `if __name__ == '__main__':` idiom

I've seen many examples of Python scripts that include a line that says: if __name__ == '__main__': Sometimes the following block contains a bunch of code, but other times it just makes a singl...

1 answer  ·  posted 12mo ago by Karl Knechtel‭  ·  last activity 12mo ago by Karl Knechtel‭

Question python startup entry-point
60%
+1 −0
Q&A Installing packages for, and using them with, a specific Python installation

I have multiple installations of Python on my machine. I already know how to choose one to use to run for my code - and therefore, I could also solve the problem for third-party application code. ...

1 answer  ·  posted 1y ago by Karl Knechtel‭  ·  last activity 1y ago by Karl Knechtel‭

Question python pip
71%
+3 −0
Q&A Understanding Virtual Environments for Python

Several times now, I've seen advice in tutorials, setup/install instructions for Python-based projects, etc. to use a virtual environment to keep things organized and make it simpler to manage the ...

1 answer  ·  posted 1y ago by Karl Knechtel‭  ·  last activity 1y ago by Karl Knechtel‭

Question python runtime-environment python-venv
71%
+3 −0
Q&A Choosing between multiple Python installations (environments) on the same computer

I have multiple installations of Python on my machine. When I run Python, what determines which installation is used? How can I control this?

1 answer  ·  posted 1y ago by Karl Knechtel‭  ·  edited 1y ago by Karl Knechtel‭

Question python installation runtime-environment
50%
+0 −0
Q&A How can I make a standalone executable from Python code?

I know that I can make Python code run starting from the script, but this still requires the user to have Python installed (and will still rely on configuring the system so that it can find Python ...

1 answer  ·  posted 1y ago by Karl Knechtel‭  ·  last activity 1y ago by Karl Knechtel‭

Question python build
77%
+5 −0
Q&A How is this code "dividing" by a string?

I found a strange expression in some Python code: from library import HOME_DIRECTORY file = HOME_DIRECTORY / "file.json" It seems to be dividing a string by another string in order to do som...

3 answers  ·  posted 1y ago by Andrew Ray‭  ·  edited 1y ago by hkotsubo‭

Question python operator-overloading operators python-3
71%
+3 −0
Q&A How do I trim a sorted list in Python?

How do I trim a sorted list in Python, so that I only keep the elements greater than a certain value? For example, if I have this list: l = [1, 3, 5, 6, 7, 8] How can I efficiently get a list of...

3 answers  ·  posted 1y ago by congusbongus‭  ·  last activity 1y ago by mellen‭

Question python array search
66%
+4 −1
Q&A Subfolders for package-less module imports

Is there some sane way to allow Python to import from subfolders in projects that don't have a package? I have many Python programs that I implemented as Python files inside a directory, without a...

1 answer  ·  posted 1y ago by matthewsnyder‭  ·  last activity 1y ago by matthewsnyder‭

Question python-3