This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Can be used as 'docker run --name=name container --entrypoint /entrypoint.sh' | |
while :; # Run an endless loop, | |
do :; # of do nothing, | |
done & # as background task. | |
kill -STOP $! # Stop the background task. | |
wait $! # Wait forever, because background task process has been stopped. | |
# Alternative is using the tail command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = 0 | |
b = 1 | |
# If a is "falsy" a is returned, b/a is not evaluated (i.e. no division by zero error). Otherwise b/a is returned. | |
print(a and b/a) | |
s = "" | |
# Returning "" if the string is "". In any other case it returns the first character in the string. | |
# Avoiding trying to indexing s when s does not have any characters or of None type. | |
print(s and s[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns a function with n preset when the function handle is created! | |
def adder(n): | |
def inner(x): | |
return x + n | |
return inner | |
# Creating preloaded functions | |
add_1 = adder(1) | |
add_100 = adder(100) |