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 |
---|---|---|---|---|
Edit | Post #291341 |
Post edited: fix code typo - `setup` was in a sub-package before Setuptools promoted it |
— | 15 days ago |
Edit | Post #291341 | Initial revision | — | 15 days ago |
Answer | — |
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 anything the standard library might or might not have. When you `import setuptools` explicitly, it furtherm... (more) |
— | 15 days ago |
Edit | Post #291340 | Initial revision | — | 15 days ago |
Question | — |
Why does `distutils` seem to be missing or broken? Isn't it part of the standard library? Sometimes when I try to install a third-party library for Python, I get an error saying that either `distutils`, or some part of it like `distutils.core` or `distutils.util`, could not be found. It's shown as a `ModuleNotFoundError`, so presumably it's coming from Python when it tries to run a `setup... (more) |
— | 15 days ago |
Comment | Post #291323 |
I agree, at least superficially. When I started writing I had it in mind that "running" the script as an executable is the same sort of thing as invoking Python to run it (since it's still asking a Python runtime to evaluate the code, just the other way around). But looking at it now - especially giv... (more) |
— | 18 days ago |
Edit | Post #291323 | Initial revision | — | 19 days ago |
Answer | — |
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 statement at a time. `python myscript.py` runs the code in `myscript.py`, assuming it's in the cur... (more) |
— | 19 days ago |
Comment | Post #291322 |
Reference questions on Stack Overflow that inspired this question:
* [Why do people write `#!/usr/bin/env python` on the first line of a Python script?](//stackoverflow.com/q/2429511)
* [How do I make a python script executable?](//stackoverflow.com/q/27494758)
* [`./xx.py: line 1: import: command... (more) |
— | 19 days ago |
Comment | Post #291322 |
This question is intended as a canonical that gathers the important, overlapping ideas from several Stack Overflow questions. The goal is to create a clear overview of Python's model for starting the execution of code.
The question is notably **not** about:
* `import`ing code (except to the ext... (more) |
— | 19 days ago |
Edit | Post #291322 | Initial revision | — | 19 days ago |
Question | — |
How and where does Python code start running? How can I control that? Suppose I have some code in a file `myscript.py` like: ``` def myfunction(): print("Test") ``` What steps do I need to take in order to make `myfunction` run? That is to say: how do I get Python to run `myscript.py`; and from there, how do I choose `myfunction` as the starting point for ... (more) |
— | 19 days ago |
Comment | Post #291286 |
What I meant was that I assume that systemd already has kernel level access and therefore doesn't have to do anything special in order to escalate other processes. But thinking about it further, that doesn't sound right - far too easily exploitable. (more) |
— | 21 days ago |
Edit | Post #291286 |
Post edited: misc typos |
— | 29 days ago |
Edit | Post #291286 | Initial revision | — | 29 days ago |
Answer | — |
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 is presumably how `systemd` is able to do it). But from your own Python program running in user-land (as ... (more) |
— | 29 days ago |
Comment | Post #291265 |
There seem to be many separate questions here. Please start by trying to make functions to implement the *individual* rules that you have in mind, and testing them. Then, the requirements for those rules need to be clearer for anyone to be able to help with them. For example, how should we know which... (more) |
— | about 1 month ago |
Comment | Post #291089 |
My take is that it failed partly because they lost interest, but mostly because the staff are so far out of touch with the community that they didn't properly understand what they were proposing to implement nor why it would be helpful. So, *the staff conception* of the idea was fundamentally flawed,... (more) |
— | about 2 months ago |
Comment | Post #291132 |
Well, I think that we accept *library and tool* recommendations, but not recommendations for software that would be targeted at end users. :) There has been a fair amount of discussion on Stack Overflow meta recently about whether people are being too strict or pedantic in excluding those sorts of qu... (more) |
— | about 2 months ago |
Comment | Post #291125 |
Even if you are not confident in your findings below the line, they certainly come across as a sincere attempt to answer the question above the line. It should be posted as an answer instead. This is a [perfectly acceptable and encouraged](https://meta.codidact.com/posts/290638) use of the site softw... (more) |
— | about 2 months ago |
Comment | Post #291068 |
> if this place is intended to be basically a wiki but in QA format, I think a lot of help/onboarding parts need a big rewrite.
You're absolutely right to be concerned, IMO. This is exactly the sort of issue that Codidact sought to address, and found fault with in SO, back at the time. However, I ... (more) |
— | about 2 months ago |
Comment | Post #291068 |
I'm inclined to agree. Just as we don't treat the OP as special with regard to "accepting" answers (a "worked for" reaction can be applied by anyone), I would prefer that the original author of a question (or answer!) is credited in proportion to the work (both quantity and quality) done on that post... (more) |
— | about 2 months ago |
Comment | Post #291089 |
> So the question is really what to do with those naive newbies. Let them be naive, and work around them? Or have them go away and come back when they get it? I mean obviously you're saying the second, I'm saying the first, but the site collectively has to settle on one and make it clear.
Ideally,... (more) |
— | about 2 months ago |
Comment | Post #291132 |
A question like this necessarily solicits either speculation or personal experience, in a way that was already found on Stack Overflow not to work well. I strongly feel that this is not something particular to Stack Overflow culture, but a consequence of the true nature of a technical Q&A site. The p... (more) |
— | about 2 months ago |
Comment | Post #291112 |
I'm afraid I don't follow. With `strcpy` or `memcpy`, it's still necessary to verify that the buffer has enough room, and it comes across to me that this is not any less work or harder to overlook.
I'm familiar with your previous Q&A and I have to admit I didn't find it very convincing. That said,... (more) |
— | about 2 months ago |
Comment | Post #291068 |
I agree that experts [should be proactively asking](https://meta.stackoverflow.com/questions/426205/) questions that are of interest to beginners (and as I already pointed out, you've had the same idea on Linux Systems).
Regarding re-asking poorly asked questions, I think you should ask a separate... (more) |
— | about 2 months ago |
Comment | Post #291089 |
Regarding workable standardized reasons to close a question, I agree that the breakdown on Stack Overflow is somewhat awkward. I've written about other possibilities on our Meta before (it may have been the overall Meta), but it won't be easy for me to find at the moment. (more) |
— | about 2 months ago |
Comment | Post #291089 |
Abuse and misunderstanding (and everything in between) of close reasons is always a concern, regardless of what the stated reasons are. But in all seriousness, a very large fraction of questions that trigger the "stupid question" emotional response *really are* overly broad, and that broadness is ver... (more) |
— | about 2 months ago |
Comment | Post #291089 |
To understand "you don't get an answer, written for you, directly to your question" as punitive, one must first presume that the opposite is a privilege. But that's simply not how a Q&A site works. In fact, "your question" already betrays a misunderstanding - that's why there is content licensing. Th... (more) |
— | about 2 months ago |
Edit | Post #291111 |
Post edited: |
— | about 2 months ago |
Edit | Post #291112 | Initial revision | — | about 2 months ago |
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) |
— | about 2 months ago |
Edit | Post #291111 | Initial revision | — | about 2 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) |
— | about 2 months ago |
Edit | Post #291034 |
Post edited: improve tagging |
— | about 2 months ago |
Suggested Edit | Post #291034 |
Suggested edit: improve tagging (more) |
helpful | about 2 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) |
— | about 2 months ago |
Edit | Post #291089 | Initial revision | — | about 2 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) |
— | about 2 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) |
— | about 2 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) |
— | about 2 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) |
— | 3 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) |
— | 3 months ago |
Edit | Post #287312 |
Post edited: Avoid unnecessarily heavy formatting; copyedit for improved flow and clarity |
— | 3 months ago |
Edit | Post #290682 | Initial revision | — | 3 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) |
— | 3 months ago |
Suggested Edit | Post #287312 |
Suggested edit: Avoid unnecessarily heavy formatting; copyedit for improved flow and clarity (more) |
helpful | 3 months ago |
Edit | Post #290681 | Initial revision | — | 3 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) |
— | 3 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) |
— | 3 months ago |