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
def save_ranking(**kwargs): | |
print(kwargs) | |
save_ranking(first='ming', second='alice', fourth='wilson', third='tom', fifth='roy') | |
# {'first': 'ming', 'second': 'alice', 'fourth': 'wilson', 'third': 'tom', 'fifth': 'roy'} |
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
def save_ranking(*args): | |
print(args) | |
save_ranking('ming', 'alice', 'tom', 'wilson', 'roy') | |
# ('ming', 'alice', 'tom', 'wilson', 'roy') |
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
def save_ranking(first, second=None, third, fourth=None): | |
... |
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 function that shows the results of running competitions consisting of 2 to 4 runners. | |
def save_ranking(first, second, third=None, fourth=None): | |
rank = {} | |
rank[1], rank[2] = first, second | |
rank[3] = third if third is not None else 'Nobody' | |
rank[4] = fourth if fourth is not None else 'Nobody' | |
print(rank) | |
# Pass the 2 positional arguments | |
save_ranking('ming', 'alice') |
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
# Initialize the zero-valued list with 100 length | |
zeros_list = [0] * 100 | |
# Declare the zero-valued tuple with 100 length | |
zeros_tuple = (0,) * 100 | |
# Extending the "vector_list" by 3 times | |
vector_list = [[1, 2, 3]] | |
for i, vector in enumerate(vector_list * 3): | |
print("{0} scalar product of vector: {1}".format((i + 1), [(i + 1) * e for e in vector])) |
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
>>> 2 * 3 | |
6 | |
>>> 2 ** 3 | |
8 | |
>>> 1.414 * 1.414 | |
1.9993959999999997 | |
>>> 1.414 ** 1.414 | |
1.6320575353248798 |
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
# Provisioning script | |
... | |
cd /opt/settings | |
git clone git@github.com/company/config.git | |
cd /opt/app | |
git clone git@github.com/company/api-server.git | |
... |
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
# /opt/settings/config.py | |
DATABASE_CONFIG = { | |
'host': 'localhost', | |
'dbname': 'company', | |
'user': 'user', | |
'password': 'password', | |
'port': 3306 | |
} | |
# main.py |
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
import os | |
from myapp import app | |
secret_key = os.environ.get('SECRET_KEY', None) | |
if not secret_key: | |
raise ValueError('You must have "SECRET_KEY" variable') | |
app.config['SECRET_KEY'] = secert_key |
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
// config.json.example | |
{ | |
"DEFAULT": { | |
"SECRET_KEY": "...", | |
"ADMIN_NAME": "...", | |
"AWS_DEFAULT_REGION": "...", | |
"MAX_IMAGE_SIZE": 5242880 | |
}, | |
"TEST": { | |
"TEST_TMP_DIR": "tests", |