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
Edit Post #290336 Initial revision over 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)
over 1 year ago
Edit Post #290335 Initial revision over 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)
over 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)
over 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)
over 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)
over 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
over 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 over 1 year ago
Edit Post #290259 Post edited:
over 1 year ago
Edit Post #290259 Initial revision over 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)
over 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)
over 1 year ago
Edit Post #290124 Post edited:
Ask directly; explicitly introduce the code; remove noise/redundancy; add language tag
over 1 year 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)
over 1 year ago
Suggested Edit Post #290124 Suggested edit:
Ask directly; explicitly introduce the code; remove noise/redundancy; add language tag
(more)
helpful over 1 year ago
Edit Post #284910 Post edited:
Explicitly indicate the error; rephrase slightly for clarity
over 1 year 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)
over 1 year ago
Suggested Edit Post #284910 Suggested edit:
Explicitly indicate the error; rephrase slightly for clarity
(more)
helpful over 1 year 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)
over 1 year ago
Edit Post #290057 Initial revision over 1 year 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)
over 1 year ago
Edit Post #290050 Post edited:
disable inappropriate auto-detected formatting for template
over 1 year ago
Suggested Edit Post #290050 Suggested edit:
disable inappropriate auto-detected formatting for template
(more)
helpful over 1 year 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)
over 1 year 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)
over 1 year 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)
over 1 year ago
Comment Post #289829 Perhaps "local" was meant to mean "only exists locally"?
(more)
over 1 year 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)
over 1 year ago
Edit Post #289754 Post edited:
over 1 year 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)
over 1 year ago
Edit Post #289759 Initial revision over 1 year ago
Answer A: Understanding mutable default arguments in Python
Possible justifications It may make sense to use a mutable default argument in the following situations: For simplicity Consider for example an argument that should be some kind of mapping, where the function will only use it for lookup without actually mutating the provided object: ``` ...
(more)
over 1 year ago
Edit Post #289756 Initial revision over 1 year ago
Answer A: Understanding mutable default arguments in Python
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-query separation; a function should take its effect either by mutating one or more parameters (a "comman...
(more)
over 1 year ago
Edit Post #289754 Initial revision over 1 year ago
Answer A: Understanding mutable default arguments in Python
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 mutate an object means to change its state - for a list, that includes adding, removing, replacing or ...
(more)
over 1 year ago
Edit Post #289753 Initial revision over 1 year ago
Question Understanding mutable default arguments in Python
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 one might expect: ``` >>> mylist = [] >>> example(mylist) ['value'] >>> example(mylis...
(more)
over 1 year ago
Comment Post #285818 Stack Exchange is dominated by Stack Overflow because it was originally an idea by and for programmers, who later realized almost as an afterthought that the same software and format could be used to build Q&A about other topics. Codidact comes years later, after seeing how the Stack Exchange model h...
(more)
over 1 year ago
Comment Post #289725 Proper answers to this will depend *strongly* on your exact needs. The Pickle format is about as general as is ever feasible, and is way overkill for most serialization.
(more)
over 1 year ago
Edit Post #289714 Post edited:
fix formatting and grammar
over 1 year ago
Comment Post #289714 This site is for concrete questions and answers. It isn't reasonable to expect "help" with figuring out a possible problem buried within dozens of lines of "code" (which seems to be a mixture of things that you wrote and messages that you got when you tried to do something). It's also impossible to u...
(more)
over 1 year ago
Suggested Edit Post #289714 Suggested edit:
fix formatting and grammar
(more)
helpful over 1 year ago
Comment Post #289251 "I just can't imagine that someone would think about tuples in this kind of scenario." I think you've misunderstood. The word "tuple" here is **only** used to describe the **result of** the non-working attempt.
(more)
over 1 year ago
Comment Post #289700 I hadn't actually thought about using a helper class for interpreting the bits of the integer used to represent universe subsets - you might consider adding an answer to refine this idea, or proposing an edit :) (Although it's not exactly clear to me that this makes things any easier than just using ...
(more)
over 1 year ago
Comment Post #289707 Sorry, I don't understand how "code obfuscation" relates to the other concepts here. Aside from that, this is a good start to the discussion, but I don't feel like I've moved significantly closer towards choosing from the options I presented....
(more)
over 1 year ago
Edit Post #289701 Initial revision over 1 year ago
Question Handling common wrong approaches and misguided motivations for basic technique questions
Background This is inspired to some extent by https://software.codidact.com/posts/289597 . I'm trying to provide a large amount of content (gradually!) that novices (mainly to Python) will find useful. The goal of the actual content is to demonstrate standard techniques and clear up common misc...
(more)
over 1 year ago
Edit Post #289700 Initial revision over 1 year ago