"""
The Session.commit() operation unconditionally issues Session.flush() before emitting COMMIT on relevant database
There are only 2 scenarios I see when session.flush() could be call manually:
- `autoflush = False`: then flush might been needed if the object need to be query in the Session
- to get the AUTOINCREMENT ID which are EVIL (🔪🔪🔪🐱)
I wrote a few examples to illustrate this.
"""
This file contains hidden or 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 asyncio | |
| from random import randint | |
| import aiofiles | |
| import request | |
| import aiohttp | |
| async def async_http_request(): | |
| """ | |
| I'm using aiohttp lib to make the http request and it's |
This file contains hidden or 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 pandas as pd | |
| import time | |
| from contextlib import contextmanager | |
| import dask.dataframe | |
| import redis | |
| import struct | |
| import numpy as np | |
| import pickle | |
Multiple inheritance can lead to multi level diamond diagram. In Python it is solved by C3 linearization.
Python doesn't need DI because it has super(). It doesn't work like parent() in other Typed programming languages such as Java or PHP.
In multiple inheritance super() doesn't call the parents but the ancestors:
class Adam(): pass
This file contains hidden or 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 sys | |
| import hashlib | |
| difficulty = 8 | |
| block = "alice:0.0001:bob:whatever" | |
| nonce = 0 | |
| zeros = "" | |
| for i in range(difficulty): | |
| zeros += "0" |