É usada para indicar o propósito ou a intenção de uma ação. Geralmente, é seguida por um verbo no infinitivo.
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
from types import TracebackType | |
from asgiref.sync import sync_to_async | |
from django.db.transaction import Atomic as _Atomic | |
__all__ = ["AtomicAsync", "Atomic"] | |
class AtomicAsync(_Atomic): | |
""" |
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
from threading import Semaphore, Thread | |
from time import sleep | |
# Número máximo de threads a serem execultadas simultaneamente | |
control_threads = Semaphore(5) | |
def view_log(number: int): | |
with control_threads: | |
print(f'O número atual é: {number}') |
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
class Test: | |
def __init__(self): | |
print("Executando construtor da classe.") | |
def __enter__(self): | |
print("Iniciando escopo da função.") | |
return self | |
def __exit__(self, exc_type, exc_val, exc_tb): | |
print("Finalizando escopo da função.") |
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
with open('test.txt', 'r') as file: | |
print(file.read()) |
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 function1(): | |
print("Case 1 selected") | |
def function2(): | |
print("Case 2 selected") | |
def default(): | |
print("Value default") | |
def switch(case): |
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 function1(): | |
print("Case 1 selected") | |
def function2(): | |
print("Case 2 selected") | |
def default(): | |
print("Value default") | |
if __name__ == "__main__": |
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
version: '3' | |
services: | |
redis-compose: | |
image: redis | |
command: redis-server --requirepass SUASENHA --appendonly yes | |
hostname: redis | |
ports: | |
- "6379:6379" | |
volumes: |
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
docker pull redis | |
docker run --name redis -p 6379:6379 -i -t -d redis |
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
version: '3' | |
services: | |
postgres-compose: | |
image: postgres | |
environment: | |
POSTGRES_USERNAME: "postgres" | |
POSTGRES_PASSWORD: "postgres" | |
ports: | |
- "5432:5432" |
NewerOlder