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
When I have tried to read technical explanations of the syntax rules for programming languages, and when I am trying to decipher error messages, I often encounter the terms expression and statement...
Before attempting this, make sure it makes sense in context. In a few particular situations, it would be better to take a different approach rather than using the normal tools for composing or f...
Would it discourage others from posting answers, if they saw that a question had an answer with a "works for me" indication applied immediately? (More so than just seeing an immediate, comprehensiv...
Never Too Late Due to, shall we say, recent AI-related hallucinations, pretty much everything that was possible PR-wise in 2019 is possible for this site again. People are leaving Stack Overflow a...
Consider this code example: def example(param=[]): param.append('value') print(param) When example is repeatedly called with an existing list, it repeatedly appends to the list, as ...
Sure, I'll step up for this, since nobody else has yet. I think my credentials speak for themselves, but just in case: I'm an accomplished Python developer with a long history of helping people ou...
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...
These two uses of if are different The if at the end of a list comprehension syntax: [num for num in hand if num != 11] is a filter; its purpose is to decide whether or not the resulting list ...
Terminology "Mutable default argument" means exactly what the individual words would suggest: it's an argument which is supplied as the default value for that parameter, which also is mutable. To ...
I want to write one or more self-answered Q&As on the topic of text encoding in Python, to serve as canonicals and preempt future lower-quality questions. I can think of the following things th...
Import modules rather than names first to avoid a circular reference in the import statements; then use forward declarations, as before, to avoid a circular reference in the type annotations - like...
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, mult...
Suppose I have some code in a file myscript.py like: def my_function(): print("Test") What steps do I need to take in order to make my_function run? That is to say: how do I get Python to ...
So far, existing Meta discussion seems to have at least hinted at the possibility of using separate categories here: To shuffle closed questions out of the way (globally for Codidact) (also) Fo...
Use at to schedule the command, using subprocess from Python to invoke at. It doesn't even require shell=True. For example: import shlex, subprocess subprocess.run( # `at` command to run n...
I think the framing of this question (and the prior discussion) is wrong, and I think that conditions have evolved since it was originally asked - in particular, we can now see how articles have tu...
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: condition_value if some...
As part of a general effort to produce basic Q&As for Python, recently I've been focused on issues related to starting up an interpreter and running the code - so, questions about setting up an...
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...
Looking back at my own Q&A How can I build a string from smaller pieces?, the answer is incredibly long. I'm essentially showing five different ways to solve the problem - because they all exis...
Workarounds Avoiding mutation Because problems are only caused by actually mutating the default argument, the simplest way to avoid problems is to... not do that. Pythonic code obeys command-quer...
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 hon...
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...
I had understood that Python is supposed to come "batteries included", and that the "batteries" specifically include: the tkinter standard library, a simple GUI framework a simple IDE cal...
There's still time This scenario is not yet a problem for this site, but we will get there, since it's a huge problem for Stack Overflow This topic should be separately addressed, too. At ti...