Dec 10, 2020
Running \?
within a psql database gives a whole list of commands that come in handy when performing various kinds of tasks.
Running \?
within a psql database gives a whole list of commands that come in handy when performing various kinds of tasks.
If you’re new to celery, start here.
Sometimes when using celery, you may want to get notified when a task running in the background executes successfully or when it fails. You may also want to run a function each time before the celery task runs or after it completes. These and many others along the same line are all situations where signals would come in handy.
What happens when a variable is assigned to another variable in python? For example:
>>> x = 5
>>> y = x
Both x
and y
will have the value 5
. But, when x
was assigned to y
, y
was not created as a completely new/separate object. Instead, an alias for x
was created. That is, y
points to the memory location of x
. It does not have it’s own memory location - yet.
>>> id(x)
140428600776960
>>> id(y)
140428600776960
>>> x is y
True
By default, variables are immutable in Rust. Coming from a Python background, I have to keep in mind that this:
fn main() {
let var = 10;
println!("var = {}", var); // var = 10
var = 5; // try and reassign var
println!("var is now {}", var);
}
… will not compile.
The range()
function is often useful when iterating over a set of integers:
for n in range(50):
...
#
for n in range(10, 30):
...
or a list of strings:
for fruit in ["apple", "mango", "banana"]:
...
Say we have a list of strings: _list = [...,]
and user input _input = '...'
, how do we find the items in _list
that most closely resemble _input
?
Python has a built-in package called difflib
with the function get_close_matches()
that can help us.
Note: * represents a required parameter.
join()
string.join(iterable)
iterable
*: a python iterable e.g a list, tuple, string, dictionary or set.
Returns a string concatenated with the elements of the passed in iterable.
capitalize()
string.capitalize()
capitalize()
takes no parameters.
Returns a copy of the string with the first letter of the first word capitalized and all the other characters of the string in lowercase.
I just came across this online HTML to JSX Compiler. If you’re new (or not) to react and you’re still having a little trouble with JSX, I think this tool is great for learning.
Note: * represents a required parameter.
find()
string.find(substring, start, end)
substring
*: the substring to be searched in the string
.
start
: index from which to begin the search.
end
: index at which to end the search.
Returns an integer value pointing to the index of first occurrence of the
substring. If the substring is not found, it returns -1
.