python -m pip install https://github.com/django/django/archive/45dfb3641aa4d9828a7c5448d11aa67c7cbd7966.tar.gz
pip install relative_path_to_seaborn.tar.gz
pip install mypackage --no-index --find-links file:///srv/pkg/mypackage
from collections import defaultdict, namedtuple
my_costs = namedtuple('M', ['type_', 'amount'])
foo = [
my_costs('food', 4),
my_costs('food', 3),
my_costs('car', 3),
my_costs('dog', 1)
]
def sumosts(min_amount, input):
expences = defaultdict(int)
for expense in input:
if expense.amount >= min_amount:
expences[expense.type_] += expense.amount
print(expences.items())
for (type_, amount) in sorted(expences.items(), key=lambda e: e[1], reverse=False):
print(type_, amount)
sumosts(1, foo)
import asyncio
from datetime import datetime
async def async_print():
print(datetime.now())
await asyncio.sleep(1)
async def gather_with_concurrency(n, *tasks):
semaphore = asyncio.Semaphore(n)
async def sem_task(task):
async with semaphore:
return await task
return await asyncio.gather(*(sem_task(task) for task in tasks))
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(
gather_with_concurrency(3, *(async_print() for _ in range(20)))
)
вопрос по базовым типам и базовым действием с этими типами