All Questions
4 questions
0
votes
2
answers
1k
views
Loop outside method or method with internal loop?
If I have a list of objects that need to have an operation performed on each, is there a best practice in abstracting the loop or not?
Looping over list and call
def func(item):
some_op(item)
...
1
vote
1
answer
2k
views
When should an argument be set to None in Python?
The focus of my question is on design.
If I have an argument that can be None and it is passed between several functions until finally being used, which function should treat it as a default argument?
...
4
votes
2
answers
263
views
Design of multi-test function to validate a string
Assume that I wish to perform an action on a string (e.g., print the string) if, and only if, the string first passes several tests. The tests are diverse (and may even be complex functions themselves)...
-3
votes
1
answer
152
views
Returning a variable or a return code from a function
Let assume that we have a main() function in which we call a createDirectory() function.
In Python for instance, the code would be:
def main():
# Do some stuff
createDirectory(myPath)
# ...