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.
Search
Use os.fork(). Example: import os import time pid = os.fork() if pid == 0: os.setsid() # Prevents the child from being killed if the parent dies time.sleep(10) os.system('some...
The list you provided seems huge for a single Q/A. I think you're better off breaking them up, and linking to each other in the answers. The theory behind text encoding can be decoupled from Python...
Ok so we have fairly lax tagging rules here, as do most Codidact sites. Recently the Electrical Engineering community has started a clean-up of strange and off-topic tags. I wrote this over there: ...
I eventually also found out that the typing module has a global variable TYPE_CHECKING that can be used to only import during type-checking. Concretely, the following code for helpers.py seems to ...
It has 2 parameters for weird historical reasons that nobody seems to know the rationale for any longer. Like most functions in the C standard library, the function API was not well-designed. Keep ...
Consider the following arbitrarily-nested JSON as input to a jq filter: echo '[{"foo": [1, 2]}, {"bar": [{"baz": ["foo", "baz"]}]}]' | jq '.' My goal is to join leaf arrays into strings: [{"fo...
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...
I ran some Python code and it crashed with ModuleNotFoundError. What is the general approach for dealing with these situations?
It seems to get to job done, but the Promise will always remain pending You must call resolve() or reject() (or throw an error) inside the executor function of the Promise, otherwise the Pro...
Found this old article at the bottom of the search results to be the best explanation to date: (The longer version is here, SSL Handshake (Sun Java System Directory Server Enterprise Edition 6.0 R...
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...
A namespace is a category to which a name can belong. Think of family names for people: I may be friends with several Jims, and if only one of them is present I can just call him Jim. But if multip...
Alexei's comment gave me the answer. Instead of using the code icon, put three backticks "```" at the start and end of the code. Each set of backticks must be on it's own line. Here's an example: ...
Compare $CI_COMMIT_BRANCH to your desired branch name in rules: # .gitlab-ci.yml stages: - test - deploy # This job will run always. test-job: stage: test image: bash script:...
I would like to download the old-time radio show I Love a Mystery from the OTRR website. I figured out how to construct the list of right URLs, const urlStub = "https://otrr.org/OTRRLibrary/jukebo...
Sylvester's answer is great, but I wanted to point out that interpolation only happens in double-quoted strings ("), not in single-quoted ones ('). If you have lines that don't need any variable o...
Based on the SO comments, this is not a good general practice, and I believe the point of the posts mentioned in the question is that it can be done (but one probably shouldn't) this can be use...
This can be done using conditional types. I defined these helper types: enum Role { server, client }; type PossiblyHiddenFromClients<R extends Role, T> = T | (R extends Role.client ? un...
Simply put: parenthesis are used whenever we suspect that there may be operator precedence issues. Either because the user passed an expression containing several operands and operators to the...
The term long predates Pytest and is not at all specific to Python. The idea is described on Wikipedia: In the context of software a test fixture (also called "test context") is used to set up s...
Note: This is a general question about Markdown formatting for any Markdown renderer (e.g., Gitlab, Github, Codidact). So this is not just a question about Codidact's renderer. When displaying she...
If you don't mind the extra memory, you can do it with an extra array: struct basket { char *item_memory; char **items; int itemcount; }; /* I omitted any error handling */ voi...
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...
In vscode, when I hit a breakpoint it automatically opens "Run and Debug" window. I don't want that because I am using a small screen (and that sidebar takes up space) and I don't always need to us...
The atoi family of functions should never be used for any purpose - they are broken by design. The reason why can be found in the C standard C23 7.24.1: The functions atof, atoi, atol, and atol...