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 »

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.

Search

Advanced Search Options

To further refine your search, you can use additional qualifiers such as score:>0.5. For example, the search score:>=0.5 created:<1y grammar would return only posts mentioning "grammar" that have a score >= 0.5 and were created less than a year ago.

Further help with searching is available in the help center.

Quick hints: tag:tagname, user:xxx, "exact phrase", post_type:xxx, created:<N{d,w,mo,y}, score:>=0.5

Filters
109 posts
 
80%
+6 −0
Code Reviews JSON log formatter

Here's a JSON log formatter for Python. I want to be able to log details of exceptions (and have some capability to debug-by-logs). I want to be able to log extra data in JSON format (in addition...

2 answers  ·  posted 1y ago by misk94555‭  ·  last activity 5mo ago by Karl Knechtel‭

Question python logging
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 10d ago by Karl Knechtel‭  ·  last activity 10d ago by Karl Knechtel‭

66%
+2 −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 6d ago by Karl Knechtel‭  ·  last activity 2d ago by matthewsnyder‭

Question python linux pip
84%
+9 −0
Q&A Why don't format specifiers work with lists, dictionaries and other objects?

When I want to print a number or a string, I can use f-strings (Python >= 3.6) or str.format, and I can use just the variable between braces, or use format specifiers. Ex: num, text = 10, 'abc' ...

1 answer  ·  posted 4y ago by hkotsubo‭  ·  edited 4y ago by sth‭

80%
+6 −0
Q&A Why is this symlink() call returning successfully while apparently failing to create the sym-link?

Summary I'm building an internal system (hardware simulator, using Rust) to help test some Python-based services that talk to hardware. (The services talk to hardware via TTYs.) To trick the Pytho...

1 answer  ·  posted 3y ago by ghost-in-the-zsh‭  ·  last activity 2y ago by ghost-in-the-zsh‭

Question rust linux
75%
+7 −1
Q&A Automatically install all packages needed

When running various Python scripts, I often need to do this annoying dance: $ python script.py ... ModuleNotFoundError: No module named 'foo' $ pip install foo $ python script.py ... Module...

3 answers  ·  posted 1y ago by matthewsnyder‭  ·  last activity 10mo ago by meta user‭

Question python-3 pip
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 10d ago by Karl Knechtel‭  ·  last activity 10d ago by Karl Knechtel‭

66%
+4 −1
Q&A How can I build a string from smaller pieces?

Suppose I have some variables like: >>> count = 8 >>> status = 'off' I want to combine them with some hard-coded text, to get a single string like 'I have 8 cans of Spam®; b...

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

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 27d ago by matthewsnyder‭  ·  last activity 25d ago by matthewsnyder‭

Question python-3
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 14d ago by Karl Knechtel‭  ·  last activity 14d ago by Karl Knechtel‭

Question python build
50%
+0 −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 10d ago by Karl Knechtel‭  ·  last activity 10d ago by Karl Knechtel‭

90%
+17 −0
Q&A What is the purpose of `if __name__ == '__main__'`?

I often see the construct if __name__ == '__main__' in Python code. For example, the queens.py demo in the Python repository ends with these two lines: if __name__ == "__main__": main() Ho...

1 answer  ·  posted 2y ago by J-hen‭  ·  last activity 2y ago by hkotsubo‭

66%
+4 −1
Q&A Load environment variables from .env file in Python 3 [closed]

In Python 2, I was able to create a file named .env within a project folder like so: # .env MY_ID=abc123 TOKEN=4567890 Then in a Python file in the same directory, I could read these variable...

0 answers  ·  posted 2y ago by qohelet‭  ·  closed 2y ago by Alexei‭

75%
+4 −0
Q&A Readable syntax for executing many callables with useful side effects

In Python, multiprocessing is easy to do if you follow a "list projection" paradigm. Say you want to take a list of inputs X and apply some function f to every x_i, such that y_i = f(x_i) and the y...

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

75%
+4 −0
Q&A What does "namespace" mean?

A well-known easter egg in Python displays some ideas about writing good Python code, credited to Tim Peters (one of the core developers). This question is about the last: Namespaces are one hon...

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

71%
+3 −0
Q&A PEP20 on namespaces: What exactly is it saying to do?

PEP20 aka the Zen of Python has a statement: Namespaces are one honking great idea -- let's do more of those! What exactly are we supposed to "do" according to this? Is it saying we should h...

1 answer  ·  posted 7mo ago by matthewsnyder‭  ·  last activity 2mo ago by BlckKnght‭

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 21d ago by Karl Knechtel‭  ·  last activity 14d ago by Karl Knechtel‭

Question python 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 14d ago by Karl Knechtel‭  ·  last activity 4d ago by Karl Knechtel‭

Question python startup
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 12d ago by Karl Knechtel‭  ·  edited 12d ago by Karl Knechtel‭

88%
+13 −0
Q&A Different behavior with relative imports when using flask vs py

I have a small new Python 3.8 Flask project with some relative import quirks. For the DB I use SQLAlchemy with Flask-Migrate. My project has the following general structure: controllers/ static/ te...

1 answer  ·  posted 4y ago by luap42‭  ·  last activity 4y ago by ajv‭

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 3y ago by Peter Taylor‭

84%
+9 −0
Q&A Open file in script's own folder

I have a Python script that needs to access some data (or configuration) file in its very own folder. For example, say script.py does something like this: with open('data.txt') as file: data ...

2 answers  ·  posted 2y ago by J-hen‭  ·  last activity 5mo ago by Karl Knechtel‭

81%
+7 −0
Q&A Console scripts in virtual environment do not output to terminal in git bash

I have console scripts in my virtual environment in \env\Scripts, installed with packages (e.g. black, pytest, coverage). If I try to execute these in Git Bash, the output is not returned to the te...

1 answer  ·  posted 2y ago by boudewijn21‭  ·  last activity 2y ago by boudewijn21‭

77%
+5 −0
Q&A How can I properly type-hint methods in different files that would lead to circular imports?

I am writing a Python package where I have two classes in different files that (indirectly) depend on each other. If I wouldn't care about type-hints, there would be no problem, but unfortunately,...

2 answers  ·  posted 10mo ago by mr Tsjolder‭  ·  edited 10mo ago by Alexei‭

50%
+0 −0
Q&A Best practices to write functions for both execution modes in Tensorflow, eager and graph mode

I regularly run into the problem that I have a Python function that I want to use in both, eager and graph execution mode. I therefore have to adjust the code so that it can handle both situations....

1 answer  ·  posted 10mo ago by daniel_s‭  ·  edited 10mo ago by daniel_s‭