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.

Activity for Karl Knechtel‭

Type On... Excerpt Status Date
Answer 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 equally well be interpreted as containing three strings, where the last is empty. Or more than that - up ...
(more)
9 months ago
Edit Post #291111 Initial revision 9 months ago
Question 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 a `char[]` buffer that I'm using to represent multiple null-terminated (ASCII) strings, one after the...
(more)
9 months ago
Edit Post #291034 Post edited:
improve tagging
9 months ago
Suggested Edit Post #291034 Suggested edit:
improve tagging
(more)
helpful 9 months ago
Comment Post #291068 Regarding the overhead of reopening closed questions, I think that merits a separate discussion on the network-wide Meta to come up with ideas for streamlining. Regarding expertise: as someone with a reasonable claim to "expertise" in Python, I would much rather feel responsible for *asking the qu...
(more)
9 months ago
Edit Post #291089 Initial revision 9 months ago
Answer A: Don't close questions for lack of detail/confusion
No. Terms like "too generic", "unclear", "too broad", "off topic" are absolutely not euphemisms for "stupid question, go away". They mean what they say; and when they are used Somewhere Else, multiple of them exist simultaneously for a reason. They are explicitly not designed to be used to judge t...
(more)
9 months ago
Comment Post #291046 Specifically: what I understood from the question so far is that you have solved the problem of making a list of strings from the input file, and now you are trying to group them. The fact that you have something else to do with those groups (compute a Cartesian product) is irrelevant (if you have di...
(more)
9 months ago
Comment Post #291046 A Q&A site isn't the right place to get code debugged. Questions are supposed to be of use to future visitors, too. To make this question appropriate, you should first decide: is this about how to solve the grouping problem, or is it about fixing the problem in the code? If you specifically want ...
(more)
9 months ago
Comment Post #290905 Is the question supposed to be about correctness, or style? If it's about correctness, did you *try* each way? Or if you're trying to offer a self-answered canonical, do you have a *reason to expect* that people would get it wrong? If it's about style, then what criteria do you consider relevant to ...
(more)
10 months ago
Comment Post #290682 That seems completely unrelated to me. Controlling where the file ends up when it's packaged (so that the existing code properly refers to its path) is a completely separate problem from actually specifying the path in the code. It should be addressed by a separate Q&A. I can imagine that question li...
(more)
10 months ago
Edit Post #287312 Post edited:
Avoid unnecessarily heavy formatting; copyedit for improved flow and clarity
11 months ago
Edit Post #290682 Initial revision 11 months ago
Answer 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. Whenever Python loads a module, a `file` attribute may be set on the resulting module object, g...
(more)
11 months ago
Suggested Edit Post #287312 Suggested edit:
Avoid unnecessarily heavy formatting; copyedit for improved flow and clarity
(more)
helpful 11 months ago
Edit Post #290681 Initial revision 11 months ago
Answer 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 constructor. Python exception constructors, by default, accept an arbitrary number of positional arguments...
(more)
11 months ago
Comment Post #278277 On Software for example, it seems appropriate that a question motivated by a typo or other similar, simple oversight - provided that the Q&A wouldn't be useful to others, i.e., it doesn't represent a mistake that *someone else* could have realistically made in earnest - should be closed. Presumably, ...
(more)
11 months ago
Comment Post #286185 The rest of what you say makes sense from a pragmatic software engineering perspective; but I struggle with the idea that this might have actually been meant as an exercise in recursion. Sure, the stack-based approach could be adapted to use the call stack implicitly, but that doesn't seem like a goo...
(more)
11 months ago
Edit Post #290580 Initial revision 11 months ago
Answer A: 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 hkotsubo's answer, as a file `balance.py`: `balance.py` ``` def usingreplace(s): if len(...
(more)
11 months ago
Edit Post #290579 Initial revision 11 months ago
Answer A: JSON log formatter
PEP 8 Four-space indentation is the community standard. There are many strategies for wrapping long lines; I have found that it's often best to just use temporary variables to avoid wrapping lines. Avoid pointless classes The `UncaughtExceptionHook` class is a textbook example of the design ...
(more)
11 months ago
Edit Post #290551 Post edited:
Fixed a few typos
11 months ago
Edit Post #290575 Post edited:
misc copyediting/typo fixes, and nicer formatting
11 months ago
Suggested Edit Post #290551 Suggested edit:
Fixed a few typos
(more)
helpful 11 months ago
Edit Post #290575 Initial revision 11 months ago
Answer 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 imports will only raise the base `ImportError`. This makes sense because an absolute import involve...
(more)
11 months ago
Comment Post #289252 I think that's out of scope for this question. The purpose isn't to showcase string formatting, but rather string *assembly*. I did touch on format specifiers, but deep within the nested details tags, and even then saying to read the documentation to understand it properly.
(more)
11 months ago
Edit Post #290342 Post edited:
Edit tags; PEP20 was written in the 2.x days and nothing about its advice is version-specific.
about 1 year ago
Suggested Edit Post #290342 Suggested edit:
Edit tags; PEP20 was written in the 2.x days and nothing about its advice is version-specific.
(more)
helpful about 1 year ago
Comment Post #290343 I appreciate the feedback, and agree that certain topics can be split off - I'll think about it in more detail. I don't require answers for them; while you're of course always welcome in the Codidact model to add your own answers, the point here is very explicitly for me to share knowledge that I alr...
(more)
about 1 year ago
Edit Post #290337 Initial revision about 1 year ago
Question 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 honking great idea -- let's do more of those! It seems that the concept of a "namespace" appears in pr...
(more)
about 1 year ago
Edit Post #289756 Post edited:
Clarify the status of PEP 671, and do some copyediting
about 1 year ago
Edit Post #290057 Post edited:
Update link to refer to new canonical I wrote for the syntax in question
about 1 year ago
Edit Post #290336 Initial revision about 1 year ago
Answer A: Does Python have a "ternary operator" (conditional evaluation operator like "?:" in other languages)?
How to do it Yes, Python has an equivalent operator. However, it's spelled with keywords rather than punctuation, and it uses a different order of operands. It looks like: ```python conditionvalue if somecondition() else notconditionvalue ``` This creates an expression, so the result can then ...
(more)
about 1 year ago
Edit Post #290335 Initial revision about 1 year ago
Question 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 somecondition(): avariable = conditionvalue else: avariable = notconditionvalue ``` However, this seems nee...
(more)
about 1 year ago
Comment Post #290329 It's not clear from this question what level of detail you were hoping to see in answers, or how technical they ought to be. If the point was to set up the opportunity to present your research findings as an answer, it would be better to re-work the question so that it matches and properly introduces...
(more)
about 1 year ago
Comment Post #290181 On a closer read, it appears that there are in fact satirical elements. However, the message is still pretty clear: the advice to start with an empty commit is useless and meant as a workaround for non-problems.
(more)
about 1 year ago
Comment Post #290181 "Apparently, there is also the practice of starting a repo with an empty commit. Read the post a couple of times, but still don't understand the reasoning (and I suspect that it is perhaps a satirical post)." - it's not satirical; it's straightforwardly a critique of the idea - hence the "doing git w...
(more)
about 1 year ago
Edit Post #279895 Post edited:
Use code formatting for code and list formatting for the list; fix some minor grammar etc. issues
about 1 year ago
Suggested Edit Post #279895 Suggested edit:
Use code formatting for code and list formatting for the list; fix some minor grammar etc. issues
(more)
helpful about 1 year ago
Edit Post #290259 Post edited:
about 1 year ago
Edit Post #290259 Initial revision about 1 year ago
Question Git-ignoring files with special characters in their names, especially newlines
My actual motivation is to understand the semantics of the .gitignore file syntax in precise detail, for a program which is expected to emulate them as accurately as possible. However, while coming up with test cases I realized an interesting problem. Suppose, on Linux, I have created a file with ...
(more)
about 1 year ago
Comment Post #290133 I'm not sure what the intended scope of the question is. Are you looking for debugging help, or trying to understand a concept? If it's about debugging, it would be best to help yourself first. Do you understand what the error means generally? Have you been able to figure out *where* in the code i...
(more)
about 1 year ago