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.

Posts by Karl Knechtel‭

93 posts
71%
+3 −0
Q&A How does the strict aliasing rule enable or prevent compiler optimizations?

Inspired by https://meta.stackoverflow.com/questions/432242, and the relevant main-space questions. I have heard that C and C++ something called the "strict aliasing rule", which means for exa...

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

71%
+3 −0
Q&A Privilege escalation from Python like from systemd

Generallly (assuming no exploit is found) it's not possible to escalate the privileges of an already running process, except via code that itself has kernel level access (running in ring 0 - this i...

posted 8mo ago by Karl Knechtel‭  ·  edited 8mo ago by Karl Knechtel‭

Answer
71%
+3 −0
Q&A Why does Pip display "error: externally-managed-environment", and what can I do about it?

Reminder: never use sudo to run Pip. This can never properly fix a problem and only introduces serious security risks. Installing third-party packages from PyPI can run arbitrary code at install ...

posted 6mo ago by Karl Knechtel‭  ·  edited 6mo ago by Karl Knechtel‭

Answer
71%
+3 −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 6mo ago by Karl Knechtel‭  ·  last activity 6mo ago by Alexei‭

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

General This question and answer are adapted from my original write-up on Stack Overflow, which you may consult for more details. This version is crafted as to be a clear overview, without referri...

posted 6mo ago by Karl Knechtel‭  ·  edited 5mo ago by Karl Knechtel‭

Answer
71%
+3 −0
Q&A Why does `pip` seem to be missing or broken? Isn't it part of the standard library?

Contrary to popular belief, Pip is not part of the Python standard library - although it comes as part of a standard distribution of Python. Pip is developed and maintained by the arms-length Pytho...

posted 6mo ago by Karl Knechtel‭  ·  edited 6mo ago by Karl Knechtel‭

Answer
71%
+3 −0
Q&A Understanding Virtual Environments for Python

Why The most important ideas behind virtual environments are: Since there is a separate site-packages, you can isolate the dependencies of your project. This is especially important for testi...

posted 6mo ago by Karl Knechtel‭

Answer
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 6mo ago by Karl Knechtel‭  ·  last activity 6mo ago by Karl Knechtel‭

Question python startup
71%
+3 −0
Meta Comparing our site scope to Stack Overflow

We've had discussions before about the site's intended scope (range of permissible topics and questions), but for new users coming from the Stack Exchange network, I think it would be useful to dra...

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

71%
+3 −0
Q&A Choosing between multiple Python installations (environments) on the same computer

This answer assumes only installations of the reference "CPython" implementation, as provided by the official website at https://www.python.org. Other installations - such as those provided by th...

posted 7mo ago by Karl Knechtel‭  ·  edited 7mo ago by Karl Knechtel‭

Answer
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 7mo ago by Karl Knechtel‭  ·  edited 6mo ago by Karl Knechtel‭

71%
+3 −0
Q&A Automatically install all packages needed

A compromise exists between automatically inferring package names (unreliable and potentially dangerous) and writing out an explicit separate requirements.txt file: script-running tools such as pip...

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

Answer
71%
+3 −0
Q&A How can I manage multiple consecutive strings in a buffer (and add more later)?

The fundamental problem here is that it is already ambiguous where the "end" of the data in the buffer is. Strings can be empty (have zero length as reported by strlen); as such, buffer could equal...

posted 9mo ago by Karl Knechtel‭

Answer
71%
+3 −0
Q&A Open file in script's own folder

Theory Relative paths are relative to the current working directory of the Python process. This can be checked from within Python using the os.getcwd function and set using the os.chdir function. ...

posted 11mo ago by Karl Knechtel‭

Answer
71%
+3 −0
Q&A How to troubleshoot ModuleNotFoundError?

Root cause ModuleNotFoundError is a kind of ImportError. It occurs when Python code tries to use an absolute import, but can't find the named module - just as the name suggests. (Failed relative i...

posted 11mo ago by Karl Knechtel‭  ·  edited 11mo ago by Karl Knechtel‭

Answer
71%
+3 −0
Q&A Understanding mutable default arguments in Python

Possible justifications It may make sense to use a mutable default argument in the following situations: For simplicity Consider for example an argument that should be some kind of mapping, wher...

posted 1y ago by Karl Knechtel‭

Answer
71%
+3 −0
Meta Handling common wrong approaches and misguided motivations for basic technique questions

Background This is inspired to some extent by https://software.codidact.com/posts/289597 . I'm trying to provide a large amount of content (gradually!) that novices (mainly to Python) will find u...

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

71%
+3 −0
Meta Are questions about (abstract) algorithms and datastructures considered on-topic?

As the author, this is my defense. Design and modeling are on-topic The site topicality documentation explicitly includes "Software design, architecture, or modeling" as on topic. There doesn't s...

posted 1y ago by Karl Knechtel‭

Answer
71%
+3 −0
Q&A How can I output / display multiple values, with controlled spacing, without building a string?

Using the write method The write method of a file offers a much more limited interface. It only accepts one argument - a string, for a file opened in text mode - and outputs just what it's given. ...

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

Answer
71%
+3 −0
Q&A How can I output / display multiple values, with controlled spacing, without building a string?

I know that I can display a single string in the terminal window like print("example") (or similarly with a string in a variable), and I know how to open text files and write to them. I also know ...

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

Question python format output
71%
+3 −0
Q&A Understanding "de Morgan's laws"

Overview de Morgan's laws are rules of logic that allow you to transform one conditional expression into another, equivalent expression. Because (in Boolean logic) two negations cancel each other ...

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

Answer
70%
+5 −1
Q&A How and where does Python code start running? How can I control that?

Starting up Python There are several key ways to use the python command from the command line: python by itself starts a REPL that allows typing in and running Python code on the fly, one sta...

posted 8mo ago by Karl Knechtel‭  ·  edited 6mo ago by Karl Knechtel‭

Answer
66%
+2 −0
Q&A How is this code "dividing" by a string?

Python allows for operators to be overloaded (the subject of a separate future Q&A). The / operator doesn't strictly mean division in a mathematical sense; it means whatever the operands define...

posted 6mo ago by Karl Knechtel‭

Answer
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 1y ago by Karl Knechtel‭  ·  last activity 1y ago by Karl Knechtel‭

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

Using and and or correctly The left-hand side and right-hand side of these operators should both be valid operands, which should each come from a comparison. Thus, we should repeat the comparison ...

posted 1mo ago by Karl Knechtel‭

Answer