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‭

99 posts
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
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
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
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 11mo ago by Karl Knechtel‭  ·  edited 10mo 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 10mo ago by Karl Knechtel‭

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

Question python pip
66%
+2 −0
Meta A milestone for Software Development - congratulations!

It seems fine to me to restrict new users in this way - most of them probably weren't getting anywhere near the old limits, or even the new ones, anyway. (It's unfortunately common on sites like th...

posted 2mo ago by Karl Knechtel‭

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

66%
+2 −0
Q&A What happened, or is happening, to other parts of the standard library? Why are they going missing?

A handful of standard library modules either have been, or will soon be, removed from the Python standard library, as part of a general cleanup effort. These modules are seen as out of date and no ...

posted 10mo ago by Karl Knechtel‭

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

venv is indeed part of the standard library. However, some Linux distros modify Python to exclude some parts for various reasons, and venv might be among them. On Debian-based Linux distros you ...

posted 10mo ago by Karl Knechtel‭

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

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

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

66%
+2 −0
Q&A Understanding the `if __name__ == '__main__':` idiom

Whenever Python loads code from a .py file, that code gets its own namespace for global variables - so they're not truly global, but per-file values. (When you look at an imported module "from outs...

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

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

66%
+2 −0
Q&A Regex to get text outside brackets

First, we need to define some semantics. While it may not matter for your actual inputs, I propose that it should be valid for the output elements - the parts of the text found outside of brackets ...

posted 10mo ago by Karl Knechtel‭

Answer
66%
+2 −0
Q&A How can I start my Python code, from the code itself?

Mac/Linux In this environment, Python scripts can be given a shebang line that tells the operating system that the file is a script, and what interpreter (i.e., Python) to use for it. Because # st...

posted 10mo ago by Karl Knechtel‭  ·  edited 9mo 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 Why does `distutils` seem to be missing or broken? Isn't it part of the standard library?

Understanding distutils and setuptools: the history The short version of "why does installing Setuptools fix the problem?" is that Setuptools provides its own distutils package, overriding anythin...

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

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

This question is inspired by If I have a char array containing strings with a null byte (\0) terminating each string, how would I add another string onto the end? on Stack Overflow. Suppose I have...

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

Question c string
66%
+2 −0
Q&A How can I provide additional information when raising an exception?

The raise statement in Python accepts either an Exception class or an instance of that class. When used with a class, Python will create and raise an instance by passing no arguments to the constru...

posted 1y ago by Karl Knechtel‭

Answer
66%
+2 −0
Code Reviews Detecting balanced parentheses in Python

Command-line timing Rather than using separate code for timing, I tried running the timeit module as a command-line tool. I wrote initial versions of the implementations based on the OP and hkotsu...

posted 1y ago by Karl Knechtel‭

Answer
66%
+4 −1
Q&A Does Python have a "ternary operator" (conditional evaluation operator like "?:" in other languages)?

Sometimes code needs to assign (or otherwise use) a value that depends on some condition. The naive approach is to use explicit branching, which in Python would look like: if some_condition(): ...

2 answers  ·  posted 1y ago by Karl Knechtel‭  ·  last activity 1y ago by matthewsnyder‭

Question python syntax
66%
+2 −0
Meta Should asking about book recommendations directly connected to software development be on-topic?

Are books special? When I see a question like this, I naturally transform it into a more general question about resources. Printed books aren't necessarily the best way to learn about programming ...

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

Answer
66%
+2 −0
Q&A Why is git merge from rather than to?

I struggle to think of any use cases for merging from. Why was the merge command designed this way? The model here is that many developers on the same project are using branches to develop fea...

posted 1y ago by Karl Knechtel‭

Answer