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 |
---|---|---|---|---|
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) |
— | 4 months ago |
Edit | Post #290580 | Initial revision | — | 4 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) |
— | 4 months ago |
Edit | Post #290579 | Initial revision | — | 4 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) |
— | 4 months ago |
Edit | Post #290551 |
Post edited: Fixed a few typos |
— | 4 months ago |
Edit | Post #290575 |
Post edited: misc copyediting/typo fixes, and nicer formatting |
— | 4 months ago |
Suggested Edit | Post #290551 |
Suggested edit: Fixed a few typos (more) |
helpful | 4 months ago |
Edit | Post #290575 | Initial revision | — | 4 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) |
— | 4 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) |
— | 4 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. |
— | 6 months 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 | 6 months 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) |
— | 6 months ago |
Edit | Post #290337 | Initial revision | — | 6 months 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) |
— | 6 months ago |
Edit | Post #289756 |
Post edited: Clarify the status of PEP 671, and do some copyediting |
— | 6 months ago |
Edit | Post #290057 |
Post edited: Update link to refer to new canonical I wrote for the syntax in question |
— | 6 months ago |
Edit | Post #290336 | Initial revision | — | 6 months 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) |
— | 6 months ago |
Edit | Post #290335 | Initial revision | — | 6 months 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) |
— | 6 months 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) |
— | 6 months 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) |
— | 6 months 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) |
— | 6 months ago |
Edit | Post #279895 |
Post edited: Use code formatting for code and list formatting for the list; fix some minor grammar etc. issues |
— | 6 months 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 | 6 months ago |
Edit | Post #290259 |
Post edited: |
— | 6 months ago |
Edit | Post #290259 | Initial revision | — | 6 months 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) |
— | 6 months 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) |
— | 7 months ago |
Edit | Post #290124 |
Post edited: Ask directly; explicitly introduce the code; remove noise/redundancy; add language tag |
— | 7 months ago |
Comment | Post #290124 |
Could you please walk us through *how you run* the code? For example, I assume there are some steps you take in order to boot a server, and then you try to visit some URL in your web browser? What URL do you use, and how did you decide it? (more) |
— | 7 months ago |
Suggested Edit | Post #290124 |
Suggested edit: Ask directly; explicitly introduce the code; remove noise/redundancy; add language tag (more) |
helpful | 7 months ago |
Edit | Post #284910 |
Post edited: Explicitly indicate the error; rephrase slightly for clarity |
— | 7 months ago |
Comment | Post #284175 |
This seems like a special case of a more general observation about floating-point inaccuracy, which seems like a more important question to ask and answer (and have near the top of the site listing). (more) |
— | 7 months ago |
Suggested Edit | Post #284910 |
Suggested edit: Explicitly indicate the error; rephrase slightly for clarity (more) |
helpful | 7 months ago |
Comment | Post #290057 |
I decided to add an answer to this old question in order to try to expand some detail and give more clarity, taking into account the comment feedback on the original answer. That answer is high-quality and very much to the point; but some readers might want a more in-depth treatment.
At some futur... (more) |
— | 7 months ago |
Edit | Post #290057 | Initial revision | — | 7 months ago |
Answer | — |
A: Why are list comprehensions written differently if you use `else`? These two uses of `if` are different The `if` at the end of a list comprehension syntax: ```python [num for num in hand if num != 11] ``` is a filter; its purpose is to decide whether or not the resulting list should contain a value that corresponds to any given `num` (`for` each one found `in... (more) |
— | 7 months ago |
Edit | Post #290050 |
Post edited: disable inappropriate auto-detected formatting for template |
— | 7 months ago |
Suggested Edit | Post #290050 |
Suggested edit: disable inappropriate auto-detected formatting for template (more) |
helpful | 7 months ago |
Comment | Post #290032 |
I always use `git add -p` for this, and had assumed that the `p` stood for "partial". I checked the documentation and indeed the long version of the flag is "patch". Interesting. (more) |
— | 7 months ago |
Comment | Post #289985 |
I already touched on this idea [here](https://software.codidact.com/posts/289599). I do like the idea that such questions go in a separate category. In the long run it will make curation easier, since all the viable duplicate targets will be in the Q&A category, which can then be used as a powerful s... (more) |
— | 7 months ago |
Comment | Post #289907 |
I started writing an answer to this question despite my misgivings, but I think they're too serious to ignore. While the general idea is excellent, there are two serious problems here:
1. Most of the question is language-agnostic (i.e. figuring out what needs to be sent to stdout); the only Python... (more) |
— | 7 months ago |
Comment | Post #289829 |
Perhaps "local" was meant to mean "only exists locally"? (more) |
— | 8 months ago |
Comment | Post #289780 |
It's probably worth pointing out that such shifting-and-book-keeping is O(N); that if order doesn't need to be preserved then the last element can simply be moved directly into the vacated space; and that removing multiple elements at once (whether identified by a separate collection of indices, by a... (more) |
— | 8 months ago |
Edit | Post #289754 |
Post edited: |
— | 8 months ago |
Comment | Post #289753 |
I want to split this up so that there is a separate question for the workarounds. It feels a bit shoehorned in here, especially since the *underlying* problem (early binding of defaults) has *other effects* (e.g. not supporting a default parameter "based on" another parameter).
Also, I plan to hav... (more) |
— | 8 months ago |
Edit | Post #289759 | Initial revision | — | 8 months ago |