In /etc/profile
:
# Banner
echo ${HOSTNAME%%.*} | figlet | lolcat
export PATH="/home/pi/.local/bin:$PATH" # for pyarchey
pyarchey
I was puzzled by this question in StackOverflow: In Excel there is NO simple way to lookup a value in a named table, where the first column is the key (see how to name a table).
I find it hard to believe that Microsoft has not gone all the way to provide a solution to its customers!
Suppose, that, in your Excel grid, you have a table like this, named sales
:
A | B | C | D | |
---|---|---|---|---|
1 | Name | Amount | Country | Quarter |
You want to create a series of key-value pairs from the command line, using the argparse library, e.g.:
command par1 par2 --set foo=hello bar="hello world" baz=5
This is typically useful when you want to clearly distinguish":
The problem with an open statement, is that it immediately allocates the file descriptor (a commodity in limited supply).
Sometimes you want something else: a file object that you want to keep in store, and to be used later or not used at all. The file descriptor should be allocated only when actually opening the file and then it should be closed as soon as possible. The benefit is that you could have an unlimited supply of file objects (not filenames), without having to worry too much about allocated file descriptors.
The git rev-parse
command returns 0 if the current directory is in a git repo and an error code otherwise.
It is thus necessary to call the bash command, suppressing stdout and stderr, in order to get the return code.
import os, subprocess
def is_git_repo():
"Check whether this is a git repo"
With Python, calling an OS command in a simple way has long been a pain in the neck, with multiple solutions continuously asked,
answered, counter-answered and sometimes deprecated (os.system
which was phased out, subprocess
,etc.).
The key is to realize that there are, really, four ways of calling an OS command from a high level language:
You might have a file in a repository, which you want to delete because it is too large (or because it contains passwords, etc.).
The following procedure will wipe a file from your repository and compress it, so your repository will be reduced in size. It will not delete your work copy.
What to do if you have a well-used API with a function returning a string, and you want to return other information without breaking the calling code?
Pass that information as attributes to the string itself! Since the standard str type does not allow it, a new class GoldenStr must be created.
In the called function, you could use the code below to write: